Mail Archives: cygwin/2003/07/29/08:19:54
Wrong list, redirecting. Please use the <cygwin at cygwin dot com> list
for all further discussion.
Igor
On Tue, 29 Jul 2003, Jørgen Nørgaard wrote:
> Hi,
>
> while using the gcj component of gcc (java compiler frontemd for gcc)
> we have found a peculiar problem with FileInputStreams on Windows
> (XP).
>
>
> Given Freader.java:
> import java.io.*;
>
> public class Freader {
> static public void main(String arg[]) {
> try {
> File f=new File("inp.txt");
> FileInputStream fis=new FileInputStream(f);
> int inp;
> int count=0;
> while ((inp=fis.read())!=-1) {
> count++;
> }
> fis.close();
> System.out.println("#1 " + count);
>
> fis=new FileInputStream(f);
> count=0;
> fis.available();
> while ((inp=fis.read())!=-1) {
> count++;
> }
> fis.close();
> System.out.println("#2 " + count);
> } catch (Exception e) {
> e.printStackTrace();
> }
> }
> }
>
>
> File inp.txt:
> weapons of mass destruction
>
>
> that should report the same number of bytes read from the file
> "inp.txt" in both cases. And does so using javac/java on both Linux
> and Windows.
>
>
> With gcj (v 3.2) on Linux the program works fine.
>
> On Windows, however, the call to 'available' seem to consume input,
> see output below.
>
>
> Is this a known issue with gcc/gcj on Windows?
>
>
> Output on windows:
> a.exe
> #1 31
> #2 30
>
> $ gcj --version
> gcj (GCC) 3.2 20020927 (prerelease)
> Copyright (C) 2002 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions. There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>
>
> The installation is from cygwin/redhat appears to be up-to-date.
> Regards,
--
http://cs.nyu.edu/~pechtcha/
|\ _,,,---,,_ pechtcha AT cs DOT nyu DOT edu
ZZZzz /,`.-'`' -. ;-;;,_ igor AT watson DOT ibm DOT com
|,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski, Ph.D.
'---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow!
"I have since come to realize that being between your mentor and his route
to the bathroom is a major career booster." -- Patrick Naughton
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -