Difference between revisions of "Read a Text File"

From Progzoo
Jump to: navigation, search
Line 19: Line 19:
 
<code>FileReader</code>.
 
<code>FileReader</code>.
 
*The while condition <code>(s=fh.readLine())!=null</code> does two
 
*The while condition <code>(s=fh.readLine())!=null</code> does two
things, it assigns the string s and it checks for null.
+
things, it assigns the string s and it checks for null.  
<p>
+
<p>  
 
The text file  
 
The text file  
 
[haggis.txt]
 
[haggis.txt]

Revision as of 09:52, 7 August 2012

You can open a text file and read each line.
  • The BufferedReader represents a text file.
  • You can create BufferedReader from an

FileReader.

  • The while condition (s=fh.readLine())!=null does two

things, it assigns the string s and it checks for null.

The text file [haggis.txt] includes some lines of text.

[Font] [Default] [Show] [Resize] [History] [Profile]