Read a Text File
BufferedReaderrepresents a text file.
- You can create
- The while condition
things, it assigns the string s and it checks for null.
The text file [haggis.txt] includes some lines of text.
Using the try structure
You can use the try feature in Java 7. This ensures that the file will be closed and disposed of even if the read fails.
- If the file is missing then the exception will be raised and caught.