BufferedReader ready method in a while loop to determine EOF?

Posted by BobTurbo on Stack Overflow See other posts from Stack Overflow or by BobTurbo
Published on 2010-12-28T04:49:23Z Indexed on 2010/12/28 4:54 UTC
Read the original article Hit count: 221

Filed under:
|

I have a large file (wikipedia english arcticles only database as xml file) I am using to read one character at a time using BufferedReader. The psuedo code is:

file = BufferedReader...

while (file.ready())
    character = file.read()

is this actually valid? Or will ready just return false when it is waiting for the HDD to return data and not actually when the EOF has been reached? I tried to use if (file.read() == -1) but seemed to run into an infinite loop that I literally could not find.

I am just wondering if it is reading the whole file as my statistics say 444 380 wikipedia pages have been read but I thought there were many more articles..

© Stack Overflow or respective owner

Related posts about java

Related posts about bufferedreader