public class InflaterInputStream extends FilterInputStream
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.Inflater,
DeflaterOutputStream| Modifier and Type | Field and 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.
|
in| Constructor and 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. |
| Modifier and Type | Method and 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()
This operation is not supported and throws
IOException. |
long |
skip(long byteCount)
Skips up to
byteCount bytes of uncompressed data. |
nullInputStream, read, readAllBytes, readNBytes, readNBytes, transferToprotected Inflater inf
protected byte[] buf
protected int len
public InflaterInputStream(InputStream is)
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.is - the InputStream to read data from.public InflaterInputStream(InputStream is, Inflater inflater)
is - the InputStream to read data from.inflater - the specific Inflater for decompressing data.public InflaterInputStream(InputStream is, Inflater inflater, int bufferSize)
Inflater as well as
the internal buffer size to be used.is - the InputStream to read data from.inflater - the specific Inflater for decompressing data.bufferSize - the size to be used for the internal buffer.public int read()
throws IOException
read in class FilterInputStreamIOException - if an error occurs reading the byte.public int read(byte[] buffer,
int byteOffset,
int byteCount)
throws IOException
byteCount bytes of decompressed data and stores it in
buffer starting at byteOffset. Returns the number of uncompressed bytes read,
or -1.read in class FilterInputStreamIOException - if the stream is closed or another IOException occurs.protected void fill()
throws IOException
IOException - if an IOException occurs.public long skip(long byteCount)
throws IOException
byteCount bytes of uncompressed data.skip in class FilterInputStreambyteCount - the number of bytes to skip.IllegalArgumentException - if byteCount < 0.IOException - if an error occurs skipping.FilterInputStream.mark(int),
FilterInputStream.reset()public int available()
throws IOException
Although consistent with the RI, this behavior is inconsistent with
InputStream.available(), and violates the Liskov
Substitution Principle. This method should not be used.
available in class FilterInputStreamIOException - if this stream is closed or an error occurspublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class FilterInputStreamIOException - If an error occurs closing the input stream.public void mark(int readlimit)
mark in class FilterInputStreamreadlimit - of no use.FilterInputStream.markSupported(),
FilterInputStream.reset()public void reset()
throws IOException
IOException.reset in class FilterInputStreamIOException - if this stream is already closed, no mark has been set or the
mark is no longer valid because more than readlimit
bytes have been read since setting the mark.FilterInputStream.mark(int),
FilterInputStream.markSupported()public boolean markSupported()
mark semantics. This type
does not support mark(), so always responds false.markSupported in class FilterInputStreamFilterInputStream.mark(int),
FilterInputStream.reset(),
FilterInputStream.skip(long)