Package net.sf.jazzlib
Class GZIPInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- net.sf.jazzlib.InflaterInputStream
-
- net.sf.jazzlib.GZIPInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
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
-
-
Field Summary
Fields Modifier and Type Field Description protected CRC32crcThe CRC-32 checksum value for uncompressed data.protected booleaneosIndicates whether or not the end of the stream has been reached.(package private) static intFCOMMENTThe mask for bit 4 of the flag byte.(package private) static intFEXTRAThe mask for bit 2 of the flag byte.(package private) static intFHCRCThe mask for bit 1 of the flag byte.(package private) static intFNAMEThe mask for bit 3 of the flag byte.(package private) static intFTEXTThe mask for bit 0 of the flag byte.static intGZIP_MAGICThe magic number found at the start of a GZIP stream.private booleanreadGZIPHeaderIndicates whether or not the GZIP header has been read in.-
Fields inherited from class net.sf.jazzlib.InflaterInputStream
buf, inf, len
-
-
Constructor Summary
Constructors Constructor Description 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the input stream.intread(byte[] buf, int offset, int len)Reads in GZIP-compressed data and stores it in uncompressed form into an array of bytes.private voidreadFooter()private voidreadHeader()Reads in the GZIP header.-
Methods inherited from class net.sf.jazzlib.InflaterInputStream
available, fill, read, skip
-
-
-
-
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
-
FTEXT
static final int FTEXT
The mask for bit 0 of the flag byte.- See Also:
- Constant Field Values
-
FHCRC
static final int FHCRC
The mask for bit 1 of the flag byte.- See Also:
- Constant Field Values
-
FEXTRA
static final int FEXTRA
The mask for bit 2 of the flag byte.- See Also:
- Constant Field Values
-
FNAME
static final int FNAME
The mask for bit 3 of the flag byte.- See Also:
- Constant Field Values
-
FCOMMENT
static final int FCOMMENT
The mask for bit 4 of the flag byte.- 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.
-
readGZIPHeader
private boolean readGZIPHeader
Indicates whether or not the GZIP header has been read in.
-
-
Constructor Detail
-
GZIPInputStream
public GZIPInputStream(java.io.InputStream in) throws java.io.IOExceptionCreates 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.IOExceptionCreates 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- ifsizeis less than or equal to 0.
-
-
Method Detail
-
close
public void close() throws java.io.IOExceptionCloses the input stream.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classInflaterInputStream- Throws:
java.io.IOException- if an error occurs during an I/O operation.
-
read
public int read(byte[] buf, int offset, int len) throws java.io.IOExceptionReads 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:
readin classInflaterInputStream- Parameters:
buf- the buffer into which the uncompressed data will be stored.offset- the offset indicating where inbufthe uncompressed data should be placed.len- the number of uncompressed bytes to be read.- Throws:
java.io.IOException
-
readHeader
private void readHeader() throws java.io.IOExceptionReads in the GZIP header.- Throws:
java.io.IOException
-
readFooter
private void readFooter() throws java.io.IOException- Throws:
java.io.IOException
-
-