GZIPInputStream (Java Platform SE 7 ) (original) (raw)
- java.io.InputStream
- java.io.FilterInputStream
- java.util.zip.InflaterInputStream
* * java.util.zip.GZIPInputStream
- java.util.zip.InflaterInputStream
- java.io.FilterInputStream
All Implemented Interfaces:
Closeable, AutoCloseable
public class GZIPInputStream
extends InflaterInputStream
This class implements a stream filter for reading compressed data in the GZIP file format.
See Also:
InflaterInputStream
Field Summary
Fields
Modifier and Type Field and Description protected CRC32 crc CRC-32 for uncompressed data. protected boolean eos Indicates end of input stream. static int GZIP_MAGIC GZIP header magic number. * ### Fields inherited from class java.util.zip.[InflaterInputStream](../../../java/util/zip/InflaterInputStream.html "class in java.util.zip") `[buf](../../../java/util/zip/InflaterInputStream.html#buf), [inf](../../../java/util/zip/InflaterInputStream.html#inf), [len](../../../java/util/zip/InflaterInputStream.html#len)` * ### 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 GZIPInputStream(InputStream in) Creates a new input stream with a default buffer size. GZIPInputStream(InputStream in, int size) Creates a new input stream with the specified buffer size. Method Summary
Methods
Modifier and Type Method and Description void close() Closes this input stream and releases any system resources associated with the stream. int read(byte[] buf, int off, int len) Reads uncompressed data into an array of bytes. * ### Methods inherited from class java.util.zip.[InflaterInputStream](../../../java/util/zip/InflaterInputStream.html "class in java.util.zip") `[available](../../../java/util/zip/InflaterInputStream.html#available%28%29), [fill](../../../java/util/zip/InflaterInputStream.html#fill%28%29), [mark](../../../java/util/zip/InflaterInputStream.html#mark%28int%29), [markSupported](../../../java/util/zip/InflaterInputStream.html#markSupported%28%29), [read](../../../java/util/zip/InflaterInputStream.html#read%28%29), [reset](../../../java/util/zip/InflaterInputStream.html#reset%28%29), [skip](../../../java/util/zip/InflaterInputStream.html#skip%28long%29)` * ### 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
* #### crc protected [CRC32](../../../java/util/zip/CRC32.html "class in java.util.zip") crc CRC-32 for uncompressed data. * #### eos protected boolean eos Indicates end of input stream. * #### GZIP\_MAGIC public static final int GZIP_MAGIC GZIP header magic number. See Also: [Constant Field Values](../../../constant-values.html#java.util.zip.GZIPInputStream.GZIP%5FMAGIC)
Constructor Detail
* #### GZIPInputStream public GZIPInputStream([InputStream](../../../java/io/InputStream.html "class in java.io") in, int size) throws [IOException](../../../java/io/IOException.html "class in java.io") Creates a new input stream with the specified buffer size. Parameters: `in` \- the input stream `size` \- the input buffer size Throws: `[ZipException](../../../java/util/zip/ZipException.html "class in java.util.zip")` \- if a GZIP format error has occurred or the compression method used is unsupported `[IOException](../../../java/io/IOException.html "class in java.io")` \- if an I/O error has occurred `[IllegalArgumentException](../../../java/lang/IllegalArgumentException.html "class in java.lang")` \- if size is <= 0 * #### GZIPInputStream public GZIPInputStream([InputStream](../../../java/io/InputStream.html "class in java.io") in) throws [IOException](../../../java/io/IOException.html "class in java.io") Creates a new input stream with a default buffer size. Parameters: `in` \- the input stream Throws: `[ZipException](../../../java/util/zip/ZipException.html "class in java.util.zip")` \- if a GZIP format error has occurred or the compression method used is unsupported `[IOException](../../../java/io/IOException.html "class in java.io")` \- if an I/O error has occurred
Method Detail
* #### read public int read(byte[] buf, int off, int len) throws [IOException](../../../java/io/IOException.html "class in java.io") Reads uncompressed data into an array of bytes. If `len` is not zero, the method will block until some input can be decompressed; otherwise, no bytes are read and `0` is returned. **Overrides:** `[read](../../../java/util/zip/InflaterInputStream.html#read%28byte[],%20int,%20int%29)` in class `[InflaterInputStream](../../../java/util/zip/InflaterInputStream.html "class in java.util.zip")` Parameters: `buf` \- the buffer into which the data is read `off` \- the start offset in the destination array `b` `len` \- the maximum number of bytes read Returns: the actual number of bytes read, or -1 if the end of the compressed input stream is reached Throws: `[NullPointerException](../../../java/lang/NullPointerException.html "class in java.lang")` \- If `buf` is `null`. `[IndexOutOfBoundsException](../../../java/lang/IndexOutOfBoundsException.html "class in java.lang")` \- If `off` is negative,`len` is negative, or `len` is greater than`buf.length - off` `[ZipException](../../../java/util/zip/ZipException.html "class in java.util.zip")` \- if the compressed input data is corrupt. `[IOException](../../../java/io/IOException.html "class in java.io")` \- if an I/O error has occurred. See Also: [FilterInputStream.in](../../../java/io/FilterInputStream.html#in) * #### close public void close() throws [IOException](../../../java/io/IOException.html "class in java.io") Closes this input stream and releases any system resources associated with the stream. **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/util/zip/InflaterInputStream.html#close%28%29)` in class `[InflaterInputStream](../../../java/util/zip/InflaterInputStream.html "class in java.util.zip")` Throws: `[IOException](../../../java/io/IOException.html "class in java.io")` \- if an I/O error has occurred See Also: [FilterInputStream.in](../../../java/io/FilterInputStream.html#in)
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.