DeflaterInputStream (Java Platform SE 7 ) (original) (raw)
- java.io.InputStream
- java.io.FilterInputStream
- java.util.zip.DeflaterInputStream
- java.io.FilterInputStream
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
Fields
Modifier and Type Field and Description protected byte[] buf Input buffer for reading compressed data. protected Deflater def Compressor for this stream. * ### Fields inherited from class java.io.[FilterInputStream](../../../java/io/FilterInputStream.html "class in java.io") `[in](../../../java/io/FilterInputStream.html#in)`
Constructor Summary
Constructors
Constructor and 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
Methods
Modifier and Type Method and Description int available() Returns 0 after EOF has been reached, otherwise always return 1. void close() Closes this input stream and its underlying input stream, discarding any pending uncompressed data. void mark(int limit) This operation is not supported. boolean markSupported() Always returns false because this input stream does not support the mark() and reset() methods. int read() Reads a single byte of compressed data from the input stream. int read(byte[] b, int off, int len) Reads compressed data into a byte array. void reset() This operation is not supported. long skip(long n) Skips over and discards data from the input stream. * ### Methods inherited from class java.io.[FilterInputStream](../../../java/io/FilterInputStream.html "class in java.io") `[read](../../../java/io/FilterInputStream.html#read%28byte[]%29)` * ### Methods inherited from class java.lang.[Object](../../../java/lang/Object.html "class in java.lang") `[clone](../../../java/lang/Object.html#clone%28%29), [equals](../../../java/lang/Object.html#equals%28java.lang.Object%29), [finalize](../../../java/lang/Object.html#finalize%28%29), [getClass](../../../java/lang/Object.html#getClass%28%29), [hashCode](../../../java/lang/Object.html#hashCode%28%29), [notify](../../../java/lang/Object.html#notify%28%29), [notifyAll](../../../java/lang/Object.html#notifyAll%28%29), [toString](../../../java/lang/Object.html#toString%28%29), [wait](../../../java/lang/Object.html#wait%28%29), [wait](../../../java/lang/Object.html#wait%28long%29), [wait](../../../java/lang/Object.html#wait%28long,%20int%29)`
Field Detail
* #### def protected final [Deflater](../../../java/util/zip/Deflater.html "class in java.util.zip") def Compressor for this stream. * #### buf protected final byte[] buf Input buffer for reading compressed data.
Constructor Detail
* #### DeflaterInputStream public DeflaterInputStream([InputStream](../../../java/io/InputStream.html "class in java.io") in) Creates a new input stream with a default compressor and buffer size. Parameters: `in` \- input stream to read the uncompressed data to Throws: `[NullPointerException](../../../java/lang/NullPointerException.html "class in java.lang")` \- if `in` is null * #### DeflaterInputStream public DeflaterInputStream([InputStream](../../../java/io/InputStream.html "class in java.io") in, [Deflater](../../../java/util/zip/Deflater.html "class in java.util.zip") defl) Creates a new input stream with the specified compressor and a default buffer size. Parameters: `in` \- input stream to read the uncompressed data to `defl` \- compressor ("deflater") for this stream Throws: `[NullPointerException](../../../java/lang/NullPointerException.html "class in java.lang")` \- if `in` or `defl` is null * #### DeflaterInputStream public DeflaterInputStream([InputStream](../../../java/io/InputStream.html "class in java.io") in, [Deflater](../../../java/util/zip/Deflater.html "class in java.util.zip") defl, int bufLen) Creates a new input stream with the specified compressor and buffer size. Parameters: `in` \- input stream to read the uncompressed data to `defl` \- compressor ("deflater") for this stream `bufLen` \- compression buffer size Throws: `[IllegalArgumentException](../../../java/lang/IllegalArgumentException.html "class in java.lang")` \- if `bufLen` is <= 0 `[NullPointerException](../../../java/lang/NullPointerException.html "class in java.lang")` \- if `in` or `defl` is null
Method Detail
* #### close public void close() throws [IOException](../../../java/io/IOException.html "class in java.io") Closes this input stream and its underlying input stream, discarding any pending uncompressed data. **Specified by:** `[close](../../../java/io/Closeable.html#close%28%29)` in interface `[Closeable](../../../java/io/Closeable.html "interface in java.io")` **Specified by:** `[close](../../../java/lang/AutoCloseable.html#close%28%29)` in interface `[AutoCloseable](../../../java/lang/AutoCloseable.html "interface in java.lang")` **Overrides:** `[close](../../../java/io/FilterInputStream.html#close%28%29)` in class `[FilterInputStream](../../../java/io/FilterInputStream.html "class in java.io")` Throws: `[IOException](../../../java/io/IOException.html "class in java.io")` \- if an I/O error occurs See Also: [FilterInputStream.in](../../../java/io/FilterInputStream.html#in) * #### read public int read() throws [IOException](../../../java/io/IOException.html "class in java.io") Reads a single byte of compressed data from the input stream. This method will block until some input can be read and compressed. **Overrides:** `[read](../../../java/io/FilterInputStream.html#read%28%29)` in class `[FilterInputStream](../../../java/io/FilterInputStream.html "class in java.io")` Returns: a single byte of compressed data, or -1 if the end of the uncompressed input stream is reached Throws: `[IOException](../../../java/io/IOException.html "class in java.io")` \- if an I/O error occurs or if this stream is already closed See Also: [FilterInputStream.in](../../../java/io/FilterInputStream.html#in) * #### read public int read(byte[] b, int off, int len) throws [IOException](../../../java/io/IOException.html "class in java.io") Reads compressed data into a byte array. This method will block until some input can be read and compressed. **Overrides:** `[read](../../../java/io/FilterInputStream.html#read%28byte[],%20int,%20int%29)` in class `[FilterInputStream](../../../java/io/FilterInputStream.html "class in java.io")` Parameters: `b` \- buffer into which the data is read `off` \- starting offset of the data within `b` `len` \- maximum number of compressed bytes to read into `b` Returns: the actual number of bytes read, or -1 if the end of the uncompressed input stream is reached Throws: `[IndexOutOfBoundsException](../../../java/lang/IndexOutOfBoundsException.html "class in java.lang")` \- if `len` \> `b.length - off` `[IOException](../../../java/io/IOException.html "class in java.io")` \- if an I/O error occurs or if this input stream is already closed See Also: [FilterInputStream.in](../../../java/io/FilterInputStream.html#in) * #### skip public long skip(long n) throws [IOException](../../../java/io/IOException.html "class in java.io") 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`. **Overrides:** `[skip](../../../java/io/FilterInputStream.html#skip%28long%29)` in class `[FilterInputStream](../../../java/io/FilterInputStream.html "class in java.io")` Parameters: `n` \- number of bytes to be skipped Returns: the actual number of bytes skipped Throws: `[IOException](../../../java/io/IOException.html "class in java.io")` \- if an I/O error occurs or if this stream is already closed * #### available public int available() throws [IOException](../../../java/io/IOException.html "class in java.io") 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:** `[available](../../../java/io/FilterInputStream.html#available%28%29)` in class `[FilterInputStream](../../../java/io/FilterInputStream.html "class in java.io")` Returns: zero after the end of the underlying input stream has been reached, otherwise always returns 1 Throws: `[IOException](../../../java/io/IOException.html "class in java.io")` \- if an I/O error occurs or if this stream is already closed * #### markSupported public boolean markSupported() Always returns `false` because this input stream does not support the [mark()](../../../java/util/zip/DeflaterInputStream.html#mark%28int%29) and [reset()](../../../java/util/zip/DeflaterInputStream.html#reset%28%29) methods. **Overrides:** `[markSupported](../../../java/io/FilterInputStream.html#markSupported%28%29)` in class `[FilterInputStream](../../../java/io/FilterInputStream.html "class in java.io")` Returns: false, always See Also: [FilterInputStream.in](../../../java/io/FilterInputStream.html#in), [InputStream.mark(int)](../../../java/io/InputStream.html#mark%28int%29), [InputStream.reset()](../../../java/io/InputStream.html#reset%28%29) * #### mark public void mark(int limit) _This operation is not supported_. **Overrides:** `[mark](../../../java/io/FilterInputStream.html#mark%28int%29)` in class `[FilterInputStream](../../../java/io/FilterInputStream.html "class in java.io")` Parameters: `limit` \- maximum bytes that can be read before invalidating the position marker See Also: [FilterInputStream.in](../../../java/io/FilterInputStream.html#in), [FilterInputStream.reset()](../../../java/io/FilterInputStream.html#reset%28%29) * #### reset public void reset() throws [IOException](../../../java/io/IOException.html "class in java.io") _This operation is not supported_. **Overrides:** `[reset](../../../java/io/FilterInputStream.html#reset%28%29)` in class `[FilterInputStream](../../../java/io/FilterInputStream.html "class in java.io")` Throws: `[IOException](../../../java/io/IOException.html "class in java.io")` \- always thrown See Also: [FilterInputStream.in](../../../java/io/FilterInputStream.html#in), [FilterInputStream.mark(int)](../../../java/io/FilterInputStream.html#mark%28int%29)
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2020, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.