Although I think that the solution is correct, (I have given 
the same advice) I think that the original solution should 
work (according to the apidoc):

>From BuffereReader.ready():
Tell whether this stream is ready to be read. A buffered 
character stream is ready if the buffer is not empty, or 
if the underlying character stream is ready. 

>From InputStreamReader.ready():

Tell whether this stream is ready to be read. An 
InputStreamReader is ready if its input buffer is not 
empty, or if bytes are available to be read from the 
underlying byte stream.

>From this I would expect that ready() returns false at 
the end of the file.

> -----Original Message-----
> From: Shapira, Yoav [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, March 10, 2004 3:15 PM
> To: Tomcat Users List
> Subject: RE: Tomcat 4.1 hangs on File Reading
> 
> 
> 
> Hi,
> 
> >Why not simply use:
> >
> >   String line = null;
> >   while ((line = bfFile.readLine()) != null) {
> >      LoginLog logEntry = getLogEntry(line); // Create log entry from
> the
> >line just read.
> >      log.add(logEntry);
> >   }
> >
> >There is no need to use 'bfFile.ready()'. This method only checks
> >whether the call to a read method may block, which is not a problem
> >at all.
> 
> I couldn't have said it any better -- good advice ;)
> 
> One thing you could have done (or still can do if you haven't changed
> the code by now) is observe your program with a profiler, or even step
> through it with a debugger, to see it never getting out if the
> while(ready) loop.
> 
> Yoav Shapira
> 
> 
> 
> This e-mail, including any attachments, is a confidential 
> business communication, and may contain information that is 
> confidential, proprietary and/or privileged.  This e-mail is 
> intended only for the individual(s) to whom it is addressed, 
> and may not be saved, copied, printed, disclosed or used by 
> anyone else.  If you are not the(an) intended recipient, 
> please immediately delete this e-mail from your computer 
> system and notify the sender.  Thank you.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to