Class BaseEncoderInputStream

java.lang.Object
java.io.InputStream
org.refcodes.codec.BaseEncoderInputStream
All Implemented Interfaces:
Closeable, AutoCloseable

public class BaseEncoderInputStream extends InputStream
The BaseEncoderInputStream encodes data read from an underlying InputStream using the configured BaseMetrics.

Decoded bytes are read lazily from the wrapped input stream and passed to a BaseEncoder. The bytes emitted by the encoder are buffered internally and returned through the regular InputStream interface.

The stream must be closed after use so that the wrapped input stream and the encoder resources are released. When the end of the wrapped input stream is reached, the encoder is finalized automatically so that any required padding characters are emitted.

  • Constructor Details

    • BaseEncoderInputStream

      public BaseEncoderInputStream(InputStream aInputStream, BaseMetrics aBaseMetrics) throws IOException
      Constructs a BaseEncoderInputStream using the given input stream and the provided base metrics.
      Parameters:
      aInputStream - The input stream providing the decoded data.
      aBaseMetrics - The base metrics used to encode the data.
      Throws:
      IOException - Thrown in case initializing the encoder caused an I/O-related problem.
    • BaseEncoderInputStream

      public BaseEncoderInputStream(File aInputFile, BaseMetrics aBaseMetrics) throws IOException
      Constructs a BaseEncoderInputStream using the given file and the provided base metrics.
      Parameters:
      aInputFile - The file providing the decoded data.
      aBaseMetrics - The base metrics used to encode the data.
      Throws:
      IOException - Thrown in case opening the file or initializing the encoder caused an I/O-related problem.
  • Method Details