Class FileReader

java.lang.Object
java.io.Reader
java.io.InputStreamReader
java.io.FileReader
All Implemented Interfaces:
Closeable,AutoCloseable,Readable

public classFileReaderextendsInputStreamReader
Reads text from character files using a default buffer size. Decoding from bytes to characters uses either a specifiedcharset or thedefault charset.

TheFileReader is meant for reading streams of characters. For reading streams of raw bytes, consider using aFileInputStream.

Since:
1.1
See Also:
  • Constructor Details

    • FileReader

      public FileReader(String fileName) throwsFileNotFoundException
      Creates a newFileReader, given the name of the file to read, using thedefault charset.
      Parameters:
      fileName - the name of the file to read
      Throws:
      FileNotFoundException - if the named file does not exist, is a directory rather than a regular file, or for some other reason cannot be opened for reading.
      See Also:
    • FileReader

      public FileReader(File file) throwsFileNotFoundException
      Creates a newFileReader, given theFile to read, using thedefault charset.
      Parameters:
      file - theFile to read
      Throws:
      FileNotFoundException - if the file does not exist, is a directory rather than a regular file, or for some other reason cannot be opened for reading.
      See Also:
    • FileReader

      public FileReader(FileDescriptor fd)
      Creates a newFileReader, given theFileDescriptor to read, using thedefault charset.
      Parameters:
      fd - theFileDescriptor to read
      See Also:
    • FileReader

      public FileReader(String fileName,Charset charset) throwsIOException
      Creates a newFileReader, given the name of the file to read and thecharset.
      Parameters:
      fileName - the name of the file to read
      charset - thecharset
      Throws:
      IOException - if the named file does not exist, is a directory rather than a regular file, or for some other reason cannot be opened for reading.
      Since:
      11
    • FileReader

      public FileReader(File file,Charset charset) throwsIOException
      Creates a newFileReader, given theFile to read and thecharset.
      Parameters:
      file - theFile to read
      charset - thecharset
      Throws:
      IOException - if the file does not exist, is a directory rather than a regular file, or for some other reason cannot be opened for reading.
      Since:
      11