java.lang.Object | ||||
↳ | java.io.InputStream | |||
↳ | java.io.FilterInputStream | |||
↳ | java.util.zip.InflaterInputStream | |||
↳ | java.util.zip.GZIPInputStream |
The GZIPInputStream
class is used to read data stored in the GZIP
format, reading and decompressing GZIP data from the underlying stream into
its buffer.
Using GZIPInputStream
is easier than ZipInputStream
because GZIP is only for compression, and is not a container for multiple files.
This code decompresses the data from a GZIP stream, similar to the gunzip(1)
utility.
InputStream is = ... GZIPInputStream zis = new GZIPInputStream(new BufferedInputStream(is)); try { // Reading from 'zis' gets you the uncompressed bytes... processStream(zis); } finally { zis.close(); }
Note that this class ignores all remaining data at the end of the last GZIP member.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | GZIP_MAGIC | The magic header for the GZIP format. |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
crc | The checksum algorithm used when handling uncompressed data. | ||||||||||
eos | Indicates the end of the input stream. |
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.util.zip.InflaterInputStream
| |||||||||||
From class
java.io.FilterInputStream
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Construct a
GZIPInputStream to read from GZIP data from the
underlying stream.
| |||||||||||
Construct a
GZIPInputStream to read from GZIP data from the
underlying stream.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Closes this stream and any underlying streams.
| |||||||||||
Reads up to
byteCount bytes of decompressed data and stores it in
buffer starting at byteOffset .
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.util.zip.InflaterInputStream
| |||||||||||
From class
java.io.FilterInputStream
| |||||||||||
From class
java.io.InputStream
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
java.io.Closeable
| |||||||||||
From interface
java.lang.AutoCloseable
|
The magic header for the GZIP format.
The checksum algorithm used when handling uncompressed data.
Construct a GZIPInputStream
to read from GZIP data from the
underlying stream.
is | the InputStream to read data from. |
---|
IOException | if an IOException occurs.
|
---|
Construct a GZIPInputStream
to read from GZIP data from the
underlying stream. Set the internal buffer size to size
.
is | the InputStream to read data from. |
---|---|
size | the internal read buffer size. |
IOException | if an IOException occurs.
|
---|
Closes this stream and any underlying streams.
IOException |
---|
Reads up to byteCount
bytes of decompressed data and stores it in
buffer
starting at byteOffset
. Returns the number of uncompressed bytes read,
or -1.
IOException |
---|