public class DeflaterInputStream extends FilterInputStream
InputStream filter to compress data. Callers read
compressed data in the "deflate" format from the uncompressed
underlying stream.| Modifier and Type | Field and Description |
|---|---|
protected byte[] |
buf |
protected Deflater |
def |
in| Constructor and Description |
|---|
DeflaterInputStream(InputStream in)
Constructs a
DeflaterInputStream with a new Deflater and an
implementation-defined default internal buffer size. |
DeflaterInputStream(InputStream in,
Deflater deflater)
Constructs a
DeflaterInputStream with the given Deflater and an
implementation-defined default internal buffer size. |
DeflaterInputStream(InputStream in,
Deflater deflater,
int bufferSize)
Constructs a
DeflaterInputStream with the given Deflater and
given internal buffer size. |
| 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 underlying input stream and discards any remaining uncompressed
data.
|
void |
mark(int limit)
This operation is not supported and does nothing.
|
boolean |
markSupported()
Returns false because
DeflaterInputStream does not support
mark/reset. |
int |
read()
Reads a byte from the compressed input stream.
|
int |
read(byte[] buffer,
int byteOffset,
int byteCount)
Reads up to
byteCount bytes of compressed data into a byte buffer. |
void |
reset()
This operation is not supported and throws
IOException. |
long |
skip(long byteCount)
Skips
byteCount bytes in this stream. |
nullInputStream, read, readAllBytes, readNBytes, readNBytes, transferToprotected final Deflater def
protected final byte[] buf
public DeflaterInputStream(InputStream in)
DeflaterInputStream with a new Deflater and an
implementation-defined default internal buffer size. in is a source of
uncompressed data, and this stream will be a source of compressed data.in - the source InputStreampublic DeflaterInputStream(InputStream in, Deflater deflater)
DeflaterInputStream with the given Deflater and an
implementation-defined default internal buffer size. in is a source of
uncompressed data, and this stream will be a source of compressed data.in - the source InputStreamdeflater - the Deflater to be used for compressionpublic DeflaterInputStream(InputStream in, Deflater deflater, int bufferSize)
DeflaterInputStream with the given Deflater and
given internal buffer size. in is a source of
uncompressed data, and this stream will be a source of compressed data.in - the source InputStreamdeflater - the Deflater to be used for compressionbufferSize - the length in bytes of the internal bufferpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class FilterInputStreamIOException - if an error occurs while closing this stream.public int read()
throws IOException
read in class FilterInputStreamIOException - if the stream is closed or another IOException occurs.public int read(byte[] buffer,
int byteOffset,
int byteCount)
throws IOException
byteCount bytes of compressed data into a byte buffer. The result will be bytes of compressed
data corresponding to an uncompressed byte or bytes read from the underlying stream.
Returns the number of bytes read or -1 if the end of the compressed input
stream has been reached.read in class FilterInputStreamIOException - if the stream is closed or another IOException occurs.public long skip(long byteCount)
throws IOException
byteCount bytes in this stream. Subsequent
calls to read will not return these bytes unless reset is
used. This implementation skips byteCount bytes in the
filtered stream.
Note: if n > Integer.MAX_VALUE, this stream will only attempt to
skip Integer.MAX_VALUE bytes.
skip in class FilterInputStreamIOException - if this stream is closed or another IOException occurs.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 boolean markSupported()
DeflaterInputStream does not support
mark/reset.markSupported in class FilterInputStreamtrue if mark() and reset() are supported,
false otherwise.FilterInputStream.mark(int),
FilterInputStream.reset(),
FilterInputStream.skip(long)public void mark(int limit)
mark in class FilterInputStreamlimit - the number of bytes that can be read from this stream before
the mark is invalidated.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()