Skip to content

Most visited

Recently visited

navigation
Added in API level 1

InflaterInputStream

public class InflaterInputStream
extends FilterInputStream

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


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:

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.

Inherited fields

From class java.io.FilterInputStream

Public constructors

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.

Public methods

int available()

Returns 0 when when this stream has exhausted its input; and 1 otherwise.

void close()

Closes the input stream.

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()

This operation is not supported and throws IOException.

long skip(long byteCount)

Skips up to byteCount bytes of uncompressed data.

Protected methods

void fill()

Fills the input buffer with data to be decompressed.

Inherited methods

From class java.io.FilterInputStream
From class java.io.InputStream
From class java.lang.Object
From interface java.io.Closeable
From interface java.lang.AutoCloseable

Fields

buf

Added in API level 1
byte[] buf

The input buffer used for decompression.

inf

Added in API level 1
Inflater inf

The inflater used for this stream.

len

Added in API level 1
int len

The length of the buffer.

Public constructors

InflaterInputStream

Added in API level 1
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 InputStream: the InputStream to read data from.

InflaterInputStream

Added in API level 1
InflaterInputStream (InputStream is, 
                Inflater inflater)

This constructor lets you pass a specifically initialized Inflater, for example one that expects no ZLIB header.

Parameters
is InputStream: the InputStream to read data from.
inflater Inflater: the specific Inflater for decompressing data.

InflaterInputStream

Added in API level 1
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 InputStream: the InputStream to read data from.
inflater Inflater: the specific Inflater for decompressing data.
bufferSize int: the size to be used for the internal buffer.

Public methods

available

Added in API level 1
int available ()

Returns 0 when when this stream has exhausted its input; and 1 otherwise. A result of 1 does not guarantee that further bytes can be returned, with or without blocking.

Although consistent with the RI, this behavior is inconsistent with available(), and violates the Liskov Substitution Principle. This method should not be used.

Returns
int 0 if no further bytes are available. Otherwise returns 1, which suggests (but does not guarantee) that additional bytes are available.
Throws
IOException if this stream is closed or an error occurs

close

Added in API level 1
void close ()

Closes the input stream.

Throws
IOException If an error occurs closing the input stream.

mark

Added in API level 1
void mark (int readlimit)

Marks the current position in the stream. This implementation overrides the super type implementation to do nothing at all.

Parameters
readlimit int: of no use.

markSupported

Added in API level 1
boolean markSupported ()

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

Returns
boolean false, always

read

Added in API level 1
int read ()

Reads a single byte of decompressed data.

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

read

Added in API level 1
int read (byte[] buffer, 
                int byteOffset, 
                int byteCount)

Reads up to byteCount bytes of decompressed data and stores it in buffer starting at byteOffset. Returns the number of uncompressed bytes read, or -1.

Parameters
buffer byte
byteOffset int
byteCount int
Returns
int
Throws
IOException

reset

Added in API level 1
void reset ()

This operation is not supported and throws IOException.

Throws
IOException

skip

Added in API level 1
long skip (long byteCount)

Skips up to byteCount bytes of uncompressed data.

Parameters
byteCount long: the number of bytes to skip.
Returns
long the number of uncompressed bytes skipped.
Throws
IllegalArgumentException if byteCount < 0.
IOException if an error occurs skipping.

Protected methods

fill

Added in API level 1
void fill ()

Fills the input buffer with data to be decompressed.

Throws
IOException if an IOException occurs.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.