public class DeflaterInputStream extends FilterInputStream
Implements an input stream filter for compressing data in the "deflate" compression format.
DeflaterOutputStream
, InflaterOutputStream
, InflaterInputStream
protected final Deflater def
Compressor for this stream.
protected final byte[] buf
Input buffer for reading compressed data.
public DeflaterInputStream(InputStream in)
Creates a new input stream with a default compressor and buffer size.
in
- input stream to read the uncompressed data toNullPointerException
- if in
is nullpublic DeflaterInputStream(InputStream in, Deflater defl)
Creates a new input stream with the specified compressor and a default buffer size.
in
- input stream to read the uncompressed data todefl
- compressor ("deflater") for this streamNullPointerException
- if in
or defl
is nullpublic DeflaterInputStream(InputStream in, Deflater defl, int bufLen)
Creates a new input stream with the specified compressor and buffer size.
in
- input stream to read the uncompressed data todefl
- compressor ("deflater") for this streambufLen
- compression buffer sizeIllegalArgumentException
- if bufLen <= 0
NullPointerException
- if in
or defl
is nullpublic void close() throws IOException
Closes this input stream and its underlying input stream, discarding any pending uncompressed data.
close
in interface Closeable
close
in interface AutoCloseable
close
in class FilterInputStream
IOException
- if an I/O error occursFilterInputStream.in
public int read() throws IOException
Reads a single byte of compressed data from the input stream. This method will block until some input can be read and compressed.
read
in class FilterInputStream
IOException
- if an I/O error occurs or if this stream is already closedFilterInputStream.in
public int read(byte[] b, int off, int len) throws IOException
Reads compressed data into a byte array. This method will block until some input can be read and compressed.
read
in class FilterInputStream
b
- buffer into which the data is readoff
- starting offset of the data within b
len
- maximum number of compressed bytes to read into b
IndexOutOfBoundsException
- if len > b.length - off
IOException
- if an I/O error occurs or if this input stream is already closedFilterInputStream.in
public long skip(long n) throws IOException
Skips over and discards data from the input stream. This method may block until the specified number of bytes are read and skipped. Note: While n
is given as a long
, the maximum number of bytes which can be skipped is Integer.MAX_VALUE
.
skip
in class FilterInputStream
n
- number of bytes to be skippedIOException
- if an I/O error occurs or if this stream is already closedpublic int available() throws IOException
Returns 0 after EOF has been reached, otherwise always return 1.
Programs should not count on this method to return the actual number of bytes that could be read without blocking
available
in class FilterInputStream
IOException
- if an I/O error occurs or if this stream is already closedpublic boolean markSupported()
Always returns false
because this input stream does not support the mark()
and reset()
methods.
markSupported
in class FilterInputStream
FilterInputStream.in
, InputStream.mark(int)
, InputStream.reset()
public void mark(int limit)
This operation is not supported.
mark
in class FilterInputStream
limit
- maximum bytes that can be read before invalidating the position markerFilterInputStream.in
, FilterInputStream.reset()
public void reset() throws IOException
This operation is not supported.
reset
in class FilterInputStream
IOException
- always thrownFilterInputStream.in
, FilterInputStream.mark(int)
© 1993–2017, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.