Class FileReader


public class FileReader extends DataReader
Obtains records from a binary stream previously written using a FileWriter.
  • Constructor Details

    • FileReader

      public FileReader(File file, boolean compressed)
      Parameters:
      file - the file to read.
      compressed - Indicates if the data is compressed and should be decompressed as it is being read.
    • FileReader

      public FileReader(InputStream inputStream, boolean compressed)
      Parameters:
      compressed - Indicates if the data is compressed and should be decompressed as it is being read.
    • FileReader

      public FileReader(File file)
      Creates a reader for an uncompressed file, such as one written by FileWriter(File).
    • FileReader

      public FileReader(DataInput in)
      Creates a reader for uncompressed records read directly from the given input.
  • Method Details

    • read

      public static Record read(DataInput in, Record record)
      Reads one record from the given input into record and returns it, without closing the input.
    • addExceptionProperties

      public DataException addExceptionProperties(DataException exception)
      Description copied from class: Endpoint
      Adds this endpoint's current state to a DataException. Since this method is called whenever an exception is thrown, subclasses should override it to add their specific information.
      Overrides:
      addExceptionProperties in class DataReader
    • isAutoCloseReader

      public boolean isAutoCloseReader()
      Indicates if the underlying input stream should be closed when this stream closes (defaults to true).
    • setAutoCloseReader

      public FileReader setAutoCloseReader(boolean autoCloseReader)
      Indicates if the underlying input stream should be closed when this stream closes (defaults to true).
    • isAutoCloseWriter

      @Deprecated public boolean isAutoCloseWriter()
      Deprecated.
      use isAutoCloseReader() instead. Indicates if the underlying input stream should be closed when this stream closes (defaults to true).
    • setAutoCloseWriter

      @Deprecated public FileReader setAutoCloseWriter(boolean autoCloseWriter)
      Deprecated.
      use setAutoCloseReader(boolean) instead. Indicates if the underlying input stream should be closed when this stream closes (defaults to true).
    • isCompressed

      public boolean isCompressed()
      Indicates if the data is compressed and should be decompressed as it is being read.
    • close

      public void close()
      Description copied from class: DataEndpoint
      Indicates that this endpoint has finished reading or writing.
      Overrides:
      close in class DataEndpoint
    • readImpl

      protected Record readImpl() throws Throwable
      Description copied from class: DataReader
      Overridden by subclasses to read the next record from this DataReader. The default implementation of DataReader.read() now insures that this method will not be called again after it returns a null.

      If no record is available, null will be returned.

      Contract for subclasses (see also docs/authoring/DataReader.md):

      Specified by:
      readImpl in class DataReader
      Throws:
      Throwable