DeflaterInputStream (Java SE 13 & JDK 13 )
- All Implemented Interfaces:
Closeable,AutoCloseable
public class DeflaterInputStream extends FilterInputStream
Implements an input stream filter for compressing data in the "deflate" compression format.
- Since:
- 1.6
- See Also:
DeflaterOutputStream,InflaterOutputStream,InflaterInputStream
-
Field Summary
-
Constructor Summary
Constructors Constructor Description DeflaterInputStream(InputStream in)Creates a new input stream with a default compressor and buffer size.
DeflaterInputStream(InputStream in, Deflater defl)Creates a new input stream with the specified compressor and a default buffer size.
DeflaterInputStream(InputStream in, Deflater defl, int bufLen)Creates a new input stream with the specified compressor and buffer size.
-
Method Summary
Modifier and Type Method Description intavailable()Returns 0 after EOF has been reached, otherwise always return 1.
voidclose()Closes this input stream and its underlying input stream, discarding any pending uncompressed data.
voidmark(int limit)This operation is not supported.
booleanmarkSupported()Always returns
falsebecause this input stream does not support themark()andreset()methods.intread()Reads a single byte of compressed data from the input stream.
intread(byte[] b, int off, int len)Reads compressed data into a byte array.
voidreset()This operation is not supported.
longskip(long n)Skips over and discards data from the input stream.
-
Field Details
-
Constructor Details
-
DeflaterInputStream
Creates a new input stream with a default compressor and buffer size.
- Parameters:
in- input stream to read the uncompressed data to- Throws:
NullPointerException- ifinis null
-
DeflaterInputStream
Creates a new input stream with the specified compressor and a default buffer size.
- Parameters:
in- input stream to read the uncompressed data todefl- compressor ("deflater") for this stream- Throws:
NullPointerException- ifinordeflis null
-
DeflaterInputStream
Creates a new input stream with the specified compressor and buffer size.
- Parameters:
in- input stream to read the uncompressed data todefl- compressor ("deflater") for this streambufLen- compression buffer size- Throws:
IllegalArgumentException- ifbufLen <= 0NullPointerException- ifinordeflis null
-
-
Method Details
-
close
Closes this input stream and its underlying input stream, discarding any pending uncompressed data.
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classFilterInputStream- Throws:
IOException- if an I/O error occurs- See Also:
FilterInputStream.in
-
read
Reads a single byte of compressed data from the input stream. This method will block until some input can be read and compressed.
- Overrides:
readin classFilterInputStream- Returns:
- a single byte of compressed data, or -1 if the end of the uncompressed input stream is reached
- Throws:
IOException- if an I/O error occurs or if this stream is already closed- See Also:
FilterInputStream.in
-
read
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.
- Overrides:
readin classFilterInputStream- Parameters:
b- buffer into which the data is readoff- starting offset of the data withinblen- maximum number of compressed bytes to read intob- Returns:
- the actual number of bytes read, or -1 if the end of the uncompressed input stream is reached
- Throws:
IndexOutOfBoundsException- iflen > b.length - offIOException- if an I/O error occurs or if this input stream is already closed- See Also:
FilterInputStream.in
-
skip
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
nis given as along, the maximum number of bytes which can be skipped isInteger.MAX_VALUE.- Overrides:
skipin classFilterInputStream- Parameters:
n- number of bytes to be skipped- Returns:
- the actual number of bytes skipped
- Throws:
IOException- if an I/O error occurs or if this stream is already closed- See Also:
InputStream.skipNBytes(long)
-
available
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
- Overrides:
availablein classFilterInputStream- Returns:
- zero after the end of the underlying input stream has been reached, otherwise always returns 1
- Throws:
IOException- if an I/O error occurs or if this stream is already closed
-
markSupported
public boolean markSupported()
Always returns
falsebecause this input stream does not support themark()andreset()methods.- Overrides:
markSupportedin classFilterInputStream- Returns:
- false, always
- See Also:
FilterInputStream.in,InputStream.mark(int),InputStream.reset()
-
mark
public void mark(int limit)
This operation is not supported.
- Overrides:
markin classFilterInputStream- Parameters:
limit- maximum bytes that can be read before invalidating the position marker- See Also:
FilterInputStream.in,FilterInputStream.reset()
-
reset
This operation is not supported.
- Overrides:
resetin classFilterInputStream- Throws:
IOException- always thrown- See Also:
FilterInputStream.in,FilterInputStream.mark(int)
-
Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2019, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.