delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/07/29/08:19:54

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
X-Authentication-Warning: slinky.cs.nyu.edu: pechtcha owned process doing -bs
Date: Tue, 29 Jul 2003 08:19:33 -0400 (EDT)
From: Igor Pechtchanski <pechtcha AT cs DOT nyu DOT edu>
Reply-To: cygwin AT cygwin DOT com
To: =?iso-8859-1?Q?J=F8rgen?= =?iso-8859-1?Q?_?= =?iso-8859-1?Q?N=F8rgaard?= <jnp AT smarttv DOT dk>
cc: cygwin AT cygwin DOT com, <cygwin-apps AT cygwin DOT com>
Subject: Re: gcj file input problem, "available" incorrect
In-Reply-To: <p06001a08bb4bf9328842@[192.168.1.249]>
Message-ID: <Pine.GSO.4.44.0307290818440.14714-100000@slinky.cs.nyu.edu>
Importance: Normal
MIME-Version: 1.0

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019