Reading Data from a File

This chapter discusses Java's FileReader and BufferedReader classes in detail. FileReader and BufferedReader classes are used together when reading data from an external file. The use of the BufferedReader class allows data to be buffered as it is read from a file before manipulating it. The readLine() method of the BufferedReader class reads a line of text from a character-oriented input stream, and puts it into a new String object.

1. Reading from Text Files

An input stream can be connected to a text file. With character-oriented input streams, characters are automatically translated from the external (disk file) format to the internal (Java char) format.

Chapter Topics:
  • Reader
  • FileReader and BufferedReader
  • readLine()
  • Text file copy program
  • C-style input loop

Question 1:

What is the ancestor class of all character-oriented input streams?

Source: Bradley Kjell,
Creative Commons License This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 License.