public class InflaterInputStream extends FilterInputStream
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.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 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. |
Modifier and Type | Method and Description |
---|---|
int |
available()
Returns whether data can be read from this stream.
|
void |
close()
Closes the input stream.
|
protected void |
fill()
Fills the input buffer with data to be decompressed.
|
int |
read()
Reads a single byte of decompressed data.
|
int |
read(byte[] buffer,
int off,
int nbytes)
Reads up to
nbytes of decompressed data and stores it in
buffer starting at off . |
long |
skip(long nbytes)
Skips up to n bytes of uncompressed data.
|
mark, markSupported, read, reset
protected 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 inf)
is
- the InputStream
to read data from.inf
- the specific Inflater
for uncompressing data.public InflaterInputStream(InputStream is, Inflater inf, int bsize)
Inflater
as well as
the internal buffer size to be used.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 int read() throws IOException
read
in class FilterInputStream
IOException
- if an error occurs reading the byte.public int read(byte[] buffer, int off, int nbytes) throws IOException
nbytes
of decompressed data and stores it in
buffer
starting at off
.read
in class FilterInputStream
buffer
- the buffer to write data to.off
- offset in buffer to start writing.nbytes
- number of bytes to read.IOException
- if an IOException occurs.protected void fill() throws IOException
IOException
- if an IOException
occurs.public long skip(long nbytes) throws IOException
skip
in class FilterInputStream
nbytes
- the number of bytes to skip.IOException
- if an error occurs skipping.public int available() throws IOException
available
in class FilterInputStream
IOException
- If an error occurs.public void close() throws IOException
close
in class FilterInputStream
IOException
- If an error occurs closing the input stream.