Home >Java >javaTutorial >Using a FileReader
The FileReader class creates a Reader object used to read the contents of a file.
The most common constructor is FileReader(String filename).
This constructor throws the FileNotFoundException exception if the file does not exist.
FileReader is derived from InputStreamReader and Reader, inheriting their methods.
FileReader is encapsulated in a BufferedReader.
Encapsulation allows access to the readLine() method, which reads lines from the file.
Closing BufferedReader (br) automatically closes the associated file.
The above is the detailed content of Using a FileReader. For more information, please follow other related articles on the PHP Chinese website!