Package org.zkoss.io

Class FileReader

All Implemented Interfaces:
Closeable, AutoCloseable, Readable

public class FileReader extends InputStreamReader
Convenience class for reading character files. Unlike java.io.FileReader, where the default character encoding is used, it accepts different character encoding.
Since:
3.0.8
Author:
tomyeh
  • Constructor Details

    • FileReader

      public FileReader(String filename, String charset) throws IOException
      Creates a new FileReader, given the name of the file to read from.
      Parameters:
      filename - the name of the file to read from
      charset - the charset to decode the file, such as UTF-8. If null, UTF-8 is assumed.
      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.
      IOException
    • FileReader

      public FileReader(File file, String charset) throws IOException
      Creates a new FileReader, given the File instance to read from.
      Parameters:
      file - the File to read from
      charset - the charset to decode the file, such as UTF-8. If null, UTF-8 is assumed.
      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.
      IOException
    • FileReader

      public FileReader(FileDescriptor fd, String charset) throws IOException
      Creates a new FileReader, given the FileDescriptor to read from.
      Parameters:
      fd - the FileDescriptor to read from
      charset - the charset to decode the file, such as UTF-8. If null, UTF-8 is assumed.
      Throws:
      IOException