Class FlateFilterDecoderStream

java.lang.Object
java.io.InputStream
java.io.FilterInputStream
org.apache.pdfbox.filter.FlateFilterDecoderStream
All Implemented Interfaces:
Closeable, AutoCloseable

public final class FlateFilterDecoderStream extends FilterInputStream
Stream based decoder for the flate filter which uses zlib/deflate compression. Use Inflater instead of InflateInputStream to avoid an EOFException due to a probably missing Z_STREAM_END, see PDFBOX-1232 for details.
  • Field Details

    • LOG

      private static final org.apache.commons.logging.Log LOG
    • isEOF

      private boolean isEOF
    • currentDataIndex

      private int currentDataIndex
    • bytesDecoded

      private int bytesDecoded
    • buffer

      private final byte[] buffer
    • decodedData

      private final byte[] decodedData
    • inflater

      private final Inflater inflater
  • Constructor Details

    • FlateFilterDecoderStream

      public FlateFilterDecoderStream(InputStream inputStream) throws IOException
      Constructor.
      Parameters:
      inputStream - The input stream to actually read from.
      Throws:
      IOException
  • Method Details

    • fetch

      private boolean fetch() throws IOException
      Throws:
      IOException
    • read

      public int read() throws IOException
      This will read the next byte from the stream.
      Overrides:
      read in class FilterInputStream
      Returns:
      The next byte read from the stream.
      Throws:
      IOException - If there is an error reading from the wrapped stream.
    • read

      public int read(byte[] data, int offset, int length) throws IOException
      This will read a chunk of data.
      Overrides:
      read in class FilterInputStream
      Parameters:
      data - The buffer to write data to.
      offset - The offset into the data stream.
      length - The number of byte to attempt to read.
      Returns:
      The number of bytes actually read.
      Throws:
      IOException - If there is an error reading data from the underlying stream.
    • close

      public void close() throws IOException
      This will close the underlying stream and release any resources.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class FilterInputStream
      Throws:
      IOException - If there is an error closing the underlying stream.
    • markSupported

      public boolean markSupported()
      mark/reset isn't supported.
      Overrides:
      markSupported in class FilterInputStream
      Returns:
      always false.
    • skip

      public long skip(long n)
      Unsupported.
      Overrides:
      skip in class FilterInputStream
      Parameters:
      n - ignored.
      Returns:
      always zero.
    • available

      public int available()
      Unsupported.
      Overrides:
      available in class FilterInputStream
      Returns:
      always zero.
    • mark

      public void mark(int readlimit)
      Unsupported.
      Overrides:
      mark in class FilterInputStream
      Parameters:
      readlimit - ignored.
    • reset

      public void reset() throws IOException
      Unsupported.
      Overrides:
      reset in class FilterInputStream
      Throws:
      IOException - always throw as reset is an unsupported feature.