On Wed, 2004-03-10 at 14:24, Ralph Einfeldt wrote: > 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. >
That was also my (mis-) understanding but from the performance of my program and the comments on people here I think I got the wrong end of the stick somewhere. I usually use Sun's class summaries and they're generally pretty good. I used it as I would have used "while(inFile)" in C, where inFile is the name of the input stream. > > -----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] -- Adam Buglass, ><> The Golden Freeway, Department of Child Health, University of Newcastle-upon-Tyne. Royal Victoria Infirmary. (0191) 2023062 "Democracy is two wolves and a lamb voting on what to have for lunch. Liberty is a well-armed lamb contesting the vote." ~Benjamin Franklin, 1759 --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
