Package java.util.zip

Class InflaterInputStream

All Implemented Interfaces:
Closeable, AutoCloseable
Direct Known Subclasses:
GZIPInputStream, ZipInputStream

public class InflaterInputStream
extends FilterInputStream
This class provides an implementation of FilterInputStream that decompresses data that was compressed using the DEFLATE algorithm (see specification). Basically it wraps the Inflater class and takes care of the buffering.
See Also:
Inflater, DeflaterOutputStream
  • Field Summary

    Fields
    Modifier and Type Field Description
    protected byte[] buf
    The input buffer used for decompression.
    protected Inflater inf
    The inflater used for this stream.
    protected int len
    The length of the buffer.

    Fields inherited from class java.io.FilterInputStream

    in
  • Constructor Summary

    Constructors
    Constructor Description
    InflaterInputStream​(InputStream is)
    This is the most basic constructor.
    InflaterInputStream​(InputStream is, Inflater inflater)
    This constructor lets you pass a specifically initialized Inflater, for example one that expects no ZLIB header.
    InflaterInputStream​(InputStream is, Inflater inflater, int bufferSize)
    This constructor lets you specify both the Inflater as well as the internal buffer size to be used.
  • Method Summary

    Modifier and Type Method Description
    int available()
    Returns 0 when when this stream has exhausted its input; and 1 otherwise.
    void close()
    Closes the input stream.
    protected void fill()
    Fills the input buffer with data to be decompressed.
    void mark​(int readlimit)
    Marks the current position in the stream.
    boolean markSupported()
    Returns whether the receiver implements mark semantics.
    int read()
    Reads a single byte of decompressed data.
    int read​(byte[] buffer, int byteOffset, int byteCount)
    Reads up to byteCount bytes of decompressed data and stores it in buffer starting at byteOffset.
    void reset()
    Reset the position of the stream to the last marked position.
    long skip​(long byteCount)
    Skips up to byteCount bytes of uncompressed data.

    Methods inherited from class java.io.InputStream

    read

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • inf

      protected Inflater inf
      The inflater used for this stream.
    • buf

      protected byte[] buf
      The input buffer used for decompression.
    • len

      protected int len
      The length of the buffer.
  • Constructor Details

    • InflaterInputStream

      public InflaterInputStream​(InputStream is)
      This is the most basic constructor. You only need to pass the InputStream from which the compressed data is to be read from. Default settings for the Inflater and internal buffer are be used. In particular the Inflater expects a ZLIB header from the input stream.
      Parameters:
      is - the InputStream to read data from.
    • InflaterInputStream

      public InflaterInputStream​(InputStream is, Inflater inflater)
      This constructor lets you pass a specifically initialized Inflater, for example one that expects no ZLIB header.
      Parameters:
      is - the InputStream to read data from.
      inflater - the specific Inflater for decompressing data.
    • InflaterInputStream

      public InflaterInputStream​(InputStream is, Inflater inflater, int bufferSize)
      This constructor lets you specify both the Inflater as well as the internal buffer size to be used.
      Parameters:
      is - the InputStream to read data from.
      inflater - the specific Inflater for decompressing data.
      bufferSize - the size to be used for the internal buffer.
  • Method Details