net.sf.jazzlib
Class GZIPInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java13.io.FilterInputStream
          extended by net.sf.jazzlib.InflaterInputStream
              extended by net.sf.jazzlib.GZIPInputStream

public class GZIPInputStream
extends InflaterInputStream

This filter stream is used to decompress a "GZIP" format stream. The "GZIP" format is described in RFC 1952.

Since:
JDK 1.1
Author:
John Leuner, Tom Tromey

Field Summary
protected  CRC32 crc
          The CRC-32 checksum value for uncompressed data.
protected  boolean eos
          Indicates whether or not the end of the stream has been reached.
static int GZIP_MAGIC
          The magic number found at the start of a GZIP stream.
 
Fields inherited from class net.sf.jazzlib.InflaterInputStream
buf, inf, len
 
Fields inherited from class java13.io.FilterInputStream
in
 
Constructor Summary
GZIPInputStream(java.io.InputStream in)
          Creates a GZIPInputStream with the default buffer size.
GZIPInputStream(java.io.InputStream in, int size)
          Creates a GZIPInputStream with the specified buffer size.
 
Method Summary
 void close()
          Closes the input stream.
 int read(byte[] buf, int offset, int len)
          Reads in GZIP-compressed data and stores it in uncompressed form into an array of bytes.
 
Methods inherited from class net.sf.jazzlib.InflaterInputStream
available, fill, read, skip
 
Methods inherited from class java13.io.FilterInputStream
mark, markSupported, read, reset
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GZIP_MAGIC

public static final int GZIP_MAGIC
The magic number found at the start of a GZIP stream.

See Also:
Constant Field Values

crc

protected CRC32 crc
The CRC-32 checksum value for uncompressed data.


eos

protected boolean eos
Indicates whether or not the end of the stream has been reached.

Constructor Detail

GZIPInputStream

public GZIPInputStream(java.io.InputStream in)
                throws java.io.IOException
Creates a GZIPInputStream with the default buffer size.

Parameters:
in - The stream to read compressed data from (in GZIP format).
Throws:
java.io.IOException - if an error occurs during an I/O operation.

GZIPInputStream

public GZIPInputStream(java.io.InputStream in,
                       int size)
                throws java.io.IOException
Creates a GZIPInputStream with the specified buffer size.

Parameters:
in - The stream to read compressed data from (in GZIP format).
size - The size of the buffer to use.
Throws:
java.io.IOException - if an error occurs during an I/O operation.
java.lang.IllegalArgumentException - if size is less than or equal to 0.
Method Detail

close

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

Overrides:
close in class InflaterInputStream
Throws:
java.io.IOException - if an error occurs during an I/O operation.
See Also:
java.io.FilterInputStream#in

read

public int read(byte[] buf,
                int offset,
                int len)
         throws java.io.IOException
Reads in GZIP-compressed data and stores it in uncompressed form into an array of bytes. The method will block until either enough input data becomes available or the compressed stream reaches its end.

Overrides:
read in class InflaterInputStream
Parameters:
buf - the buffer into which the uncompressed data will be stored.
offset - the offset indicating where in buf the uncompressed data should be placed.
len - the number of uncompressed bytes to be read.
Returns:
the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
Throws:
java.io.IOException - if an I/O error occurs.
See Also:
java.io.FilterInputStream#in