java.util.zip
Class GZIPInputStream

java.lang.Object
  extended byjava.io.InputStream
      extended byjava.io.FilterInputStream
          extended byjava.util.zip.InflaterInputStream
              extended byjava.util.zip.GZIPInputStream

public class GZIPInputStream
extends InflaterInputStream

This class implements a stream filter for reading compressed data in the GZIP format.

Author:
David Connelly
See Also:
InflaterInputStream

Field Summary
private  boolean closed
           
protected  CRC32 crc
          CRC-32 for uncompressed data.
protected  boolean eos
          Indicates end of input stream.
private static int FCOMMENT
           
private static int FEXTRA
           
private static int FHCRC
           
private static int FNAME
           
private static int FTEXT
           
static int GZIP_MAGIC
          GZIP header magic number.
private  byte[] tmpbuf
           
 
Fields inherited from class java.util.zip.InflaterInputStream
buf, inf, len, usesDefaultInflater
 
Fields inherited from class java.io.FilterInputStream
in
 
Fields inherited from class java.io.InputStream
 
Constructor Summary
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
 void close()
          Closes the input stream.
private  void ensureOpen()
          Check to make sure that this stream has not been closed
 int read(byte[] buf, int off, int len)
          Reads uncompressed data into an array of bytes.
private  void readHeader()
           
private  void readTrailer()
           
private  int readUByte(InputStream in)
           
private  long readUInt(InputStream in)
           
private  int readUShort(InputStream in)
           
private  void skipBytes(InputStream in, int n)
           
 
Methods inherited from class java.util.zip.InflaterInputStream
available, fill, read, skip
 
Methods inherited from class java.io.FilterInputStream
mark, markSupported, read, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

crc

protected CRC32 crc
CRC-32 for uncompressed data.


eos

protected boolean eos
Indicates end of input stream.


closed

private boolean closed

GZIP_MAGIC

public static final int GZIP_MAGIC
GZIP header magic number.

See Also:
Constant Field Values

FTEXT

private static final int FTEXT
See Also:
Constant Field Values

FHCRC

private static final int FHCRC
See Also:
Constant Field Values

FEXTRA

private static final int FEXTRA
See Also:
Constant Field Values

FNAME

private static final int FNAME
See Also:
Constant Field Values

FCOMMENT

private static final int FCOMMENT
See Also:
Constant Field Values

tmpbuf

private byte[] tmpbuf
Constructor Detail

GZIPInputStream

public GZIPInputStream(InputStream in,
                       int size)
                throws IOException
Creates a new input stream with the specified buffer size.

Parameters:
in - the input stream
size - the input buffer size
Throws:
IOException - if an I/O error has occurred
IllegalArgumentException - if size is <= 0

GZIPInputStream

public GZIPInputStream(InputStream in)
                throws IOException
Creates a new input stream with a default buffer size.

Parameters:
in - the input stream
Throws:
IOException - if an I/O error has occurred
Method Detail

ensureOpen

private void ensureOpen()
                 throws IOException
Check to make sure that this stream has not been closed

Throws:
IOException

read

public int read(byte[] buf,
                int off,
                int len)
         throws IOException
Reads uncompressed data into an array of bytes. Blocks until enough input is available for decompression.

Overrides:
read in class InflaterInputStream
Parameters:
buf - the buffer into which the data is read
off - the start offset of the data
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:
IOException - if an I/O error has occurred or the compressed input data is corrupt

close

public void close()
           throws IOException
Closes the input stream.

Overrides:
close in class InflaterInputStream
Throws:
IOException - if an I/O error has occurred

readHeader

private void readHeader()
                 throws IOException
Throws:
IOException

readTrailer

private void readTrailer()
                  throws IOException
Throws:
IOException

readUInt

private long readUInt(InputStream in)
               throws IOException
Throws:
IOException

readUShort

private int readUShort(InputStream in)
                throws IOException
Throws:
IOException

readUByte

private int readUByte(InputStream in)
               throws IOException
Throws:
IOException

skipBytes

private void skipBytes(InputStream in,
                       int n)
                throws IOException
Throws:
IOException