Read data from a text file using Java

Posted by Saran on Stack Overflow See other posts from Stack Overflow or by Saran
Published on 2010-05-19T09:05:03Z Indexed on 2010/05/19 9:10 UTC
Read the original article Hit count: 337

Filed under:
|
|

I need to read a text file line by line using Java. I use available() method of FileInputStream to check and loop over the file. But while reading, the loop terminates after the line before the last one. i.e., if the file has 10lines, the loop reads only the first 9 lines. Snippet used :

while(fis.available() > 0)
{
    char c = (char)fis.read();
    .....
    .....
}

© Stack Overflow or respective owner

Related posts about java

Related posts about fileinputstream