public class

GZIPInputStream

extends InflaterInputStream
java.lang.Object
   ↳ java.io.InputStream
     ↳ java.io.FilterInputStream
       ↳ java.util.zip.InflaterInputStream
         ↳ java.util.zip.GZIPInputStream

Class Overview

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.

Summary

Constants
int GZIP_MAGIC The magic header for the GZIP format.
Fields
protected CRC32 crc The checksum algorithm used when handling uncompressed data.
protected boolean eos Indicates the end of the input stream.
[Expand]
Inherited Fields
From class java.util.zip.InflaterInputStream
From class java.io.FilterInputStream
Public Constructors
GZIPInputStream(InputStream is)
Construct a GZIPInputStream to read from GZIP data from the underlying stream.
GZIPInputStream(InputStream is, int size)
Construct a GZIPInputStream to read from GZIP data from the underlying stream.
Public Methods
void close()
Closes this stream and any underlying streams.
int read(byte[] buffer, int off, int nbytes)
Reads and decompresses GZIP data from the underlying stream into the given buffer.
[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

Constants

public static final int GZIP_MAGIC

Since: API Level 1

The magic header for the GZIP format.

Constant Value: 35615 (0x00008b1f)

Fields

protected CRC32 crc

Since: API Level 1

The checksum algorithm used when handling uncompressed data.

protected boolean eos

Since: API Level 1

Indicates the end of the input stream.

Public Constructors

public GZIPInputStream (InputStream is)

Since: API Level 1

Construct a GZIPInputStream to read from GZIP data from the underlying stream.

Parameters
is the InputStream to read data from.
Throws
IOException if an IOException occurs.

public GZIPInputStream (InputStream is, int size)

Since: API Level 1

Construct a GZIPInputStream to read from GZIP data from the underlying stream. Set the internal buffer size to size.

Parameters
is the InputStream to read data from.
size the internal read buffer size.
Throws
IOException if an IOException occurs.

Public Methods

public void close ()

Since: API Level 1

Closes this stream and any underlying streams.

Throws
IOException

public int read (byte[] buffer, int off, int nbytes)

Since: API Level 1

Reads and decompresses GZIP data from the underlying stream into the given buffer.

Parameters
buffer Buffer to receive data
off Offset in buffer to store data
nbytes Number of bytes to read
Returns
  • Number of uncompressed bytes read
Throws
IOException