You havae already learned how to chain an
OutputStreamWriter to a
FileOutputStream and an
InputStreamReader to a
FileInputStream.
Although this is not hard, Java provides two utility classes that take care of the details,
java.io.FileWriter and
java.io.FileReader.
We will look at
FileReader in this lesson and examine
FileWriter in the next lesson.
The
FileReader class reads text files using the platform's default character encoding and the default buffer size.
If you need to change the encoding and/or buffer size, construct an
InputStreamReader on a
FileInputStream instead.
There are three
FileReader constructors.
Only the constructors are declared in this class.
You use the standard
Reader methods like
read(),
ready(), and
close() to actually read the data in the file.