public class

InflaterInputStream

extends FilterInputStream
java.lang.Object
   ↳ java.io.InputStream
     ↳ java.io.FilterInputStream
       ↳ java.util.zip.InflaterInputStream
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

This class provides an implementation of FilterInputStream that uncompresses data that was compressed using the DEFLATE algorithm (see specification). Basically it wraps the Inflater class and takes care of the buffering.

Summary

Fields
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.
[Expand]
Inherited Fields
From class java.io.FilterInputStream
Public Constructors
InflaterInputStream(InputStream is)
This is the most basic constructor.
InflaterInputStream(InputStream is, Inflater inf)
This constructor lets you pass a specifically initialized Inflater, for example one that expects no ZLIB header.
InflaterInputStream(InputStream is, Inflater inf, int bsize)
This constructor lets you specify both the Inflater as well as the internal buffer size to be used.
Public Methods
int available()
Returns whether data can be read from this stream.
void close()
Closes the input stream.
void mark(int readlimit)
This implementation overrides the super type implementation to do nothing at all.
boolean markSupported()
Returns whether the receiver implements mark semantics.
int read(byte[] buffer, int off, int nbytes)
Reads up to nbytes of decompressed data and stores it in buffer starting at off.
int read()
Reads a single byte of decompressed data.
void reset()
Reset the position of the stream to the last marked position.
long skip(long nbytes)
Skips up to n bytes of uncompressed data.
Protected Methods
void fill()
Fills the input buffer with data to be decompressed.
[Expand]
Inherited Methods
From class java.io.FilterInputStream
From class java.io.InputStream
From class java.lang.Object
From interface java.io.Closeable

Fields

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.

Public Constructors

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.

public InflaterInputStream (InputStream is, Inflater inf)

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.
inf the specific Inflater for uncompressing data.

public InflaterInputStream (InputStream is, Inflater inf, int bsize)

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.
inf the specific Inflater for uncompressing data.
bsize the size to be used for the internal buffer.

Public Methods

public int available ()

Returns whether data can be read from this stream.

Returns
  • 0 if this stream has been closed, 1 otherwise.
Throws
IOException If an error occurs.

public void close ()

Closes the input stream.

Throws
IOException If an error occurs closing the input stream.

public void mark (int readlimit)

This implementation overrides the super type implementation to do nothing at all.

Parameters
readlimit of no use.

public boolean markSupported ()

Returns whether the receiver implements mark semantics. This type does not support mark(), so always responds false.

Returns
  • false, always

public int read (byte[] buffer, int off, int nbytes)

Reads up to nbytes of decompressed data and stores it in buffer starting at off.

Parameters
buffer the buffer to write data to.
off offset in buffer to start writing.
nbytes number of bytes to read.
Returns
  • Number of uncompressed bytes read
Throws
IOException if an IOException occurs.

public int read ()

Reads a single byte of decompressed data.

Returns
  • the byte read.
Throws
IOException if an error occurs reading the byte.

public void reset ()

Reset the position of the stream to the last marked position. This implementation overrides the supertype implementation and always throws an IOException when called.

Throws
IOException if the method is called

public long skip (long nbytes)

Skips up to n bytes of uncompressed data.

Parameters
nbytes the number of bytes to skip.
Returns
  • the number of uncompressed bytes skipped.
Throws
IOException if an error occurs skipping.

Protected Methods

protected void fill ()

Fills the input buffer with data to be decompressed.

Throws
IOException if an IOException occurs.