Read a Text File

From Progzoo
Revision as of 12:44, 31 December 2007 by 77.97.233.91 (talk) (New page: You can open a text file and read each line. ==Reading lines== <question xmlns:htm="http://www.w3.org/1999/xhtml" lang="java" className="Demo"><prog> import java.io.BufferedReader; import ...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

You can open a text file and read each line.

Reading lines

  • The BufferedReader represents a text file.
  • You can create BufferedReader from a

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 haggis.txt] includes some lines of text.

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