title: Read data from a text file using Java
body: <p>I need to read a text file line by line using Java. I use <code>available()</code> method of <code>FileInputStream</code> to check and loop over the file. But while reading, the loop terminates after the line before the last one. <em>i.e.</em>, if the file has 10 lines, the loop reads only the first 9 lines. 
  Snippet used : </p>
  
  <pre><code>while(fis.available() &gt; 0)
  {
      char c = (char)fis.read();
      .....
      .....
  }
  </code></pre>