public class GzipReader extends java.lang.Object implements java.io.Closeable
| Modifier and Type | Class and Description |
|---|---|
protected static class |
GzipReader.GzipEntryInputStream
InputStream to expose GZip'ed data in a controlled fashion. |
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
bIsCompliant
Compliance status for records parsed up to now.
|
protected long |
consumed
Number of bytes consumed by this reader.
|
protected java.util.zip.CRC32 |
crc
Checksum object used to calculate CRC16 and CRC32 values.
|
protected byte[] |
crc16Bytes
Buffer used to read the CRC16 value.
|
static int |
DEFAULT_INPUT_BUFFER_SIZE
Default input buffer size.
|
Diagnostics |
diagnostics
Validation errors and warnings.
|
protected int |
entries
Entries read.
|
protected byte[] |
fcommentBytes
Buffer used to read the FCOMMENT data.
|
protected byte[] |
fnameBytes
Buffer used to read the FNAME data.
|
protected GzipEntry |
gzipEntry
Current GZip entry object.
|
protected byte[] |
headerBytes
Buffer used to read header.
|
protected java.util.zip.Inflater |
inf
Inflater used to uncompress GZip entries.
|
protected byte[] |
inputBytes
Input buffer used to feed the inflater.
|
protected ISO8859_1 |
iso8859_1
ISO-8859-1 validating de-/encoder.
|
protected int |
lastInput
Last number of bytes read into the input buffer.
|
GzipEntry |
partialEntry
Partial GZip entry which could not be completely read.
|
protected ByteCountingPushBackInputStream |
pbin
Input stream of GZip (multi-part) file.
|
protected byte[] |
skip_read_buffer
Read buffer used by the skip method.
|
static int |
SKIP_READ_BUFFER_SIZE
Buffer size to use when read skipping.
|
protected long |
startOffset
Entry offset, updated each time an entry is closed.
|
protected byte[] |
trailerBytes
Buffer used to read trailer.
|
protected byte[] |
xlenBytes
Buffer used to read the XLEN value.
|
| Constructor and Description |
|---|
GzipReader(java.io.InputStream in)
Construct a GZip reader with a default input buffer size of
DEFAULT_INPUT_BUFFER_SIZE.
|
GzipReader(java.io.InputStream in,
int buffer_size)
Construct a GZip reader with the specified input buffer size.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Release resources associated with this reader.
|
long |
getConsumed()
Get number of bytes consumed by this reader.
|
GzipEntry |
getNextEntry()
Get the next GZip entry header and prepare the compressed data for
input stream retrieval.
|
long |
getOffset()
Returns the current offset in the input stream.
|
long |
getStartOffset()
Returns the offset of the current entry or -1 if none have been read.
|
boolean |
isCompliant()
Returns a boolean indicating whether all entries parsed so far are compliant.
|
static boolean |
isGzipped(ByteCountingPushBackInputStream pbin)
Check head of
PushBackInputStream for a GZip magic number. |
protected int |
readInflated(byte[] b,
int off,
int len)
Read and uncompress data into a buffer.
|
protected void |
readTrailer(GzipEntry entry)
Read the non-compressed trailing 8 bytes with CRC32 and ISize values.
|
protected byte[] |
readZeroTerminated()
Read non-compressed zero terminated data.
|
public static final int SKIP_READ_BUFFER_SIZE
protected byte[] skip_read_buffer
public static final int DEFAULT_INPUT_BUFFER_SIZE
protected ByteCountingPushBackInputStream pbin
protected java.util.zip.Inflater inf
protected java.util.zip.CRC32 crc
protected int lastInput
protected byte[] inputBytes
protected boolean bIsCompliant
public final Diagnostics diagnostics
protected int entries
protected long startOffset
protected long consumed
public GzipEntry partialEntry
protected byte[] headerBytes
protected byte[] xlenBytes
protected byte[] fnameBytes
protected byte[] fcommentBytes
protected byte[] crc16Bytes
protected byte[] trailerBytes
public GzipReader(java.io.InputStream in)
in - input stream of GZip filepublic GzipReader(java.io.InputStream in, int buffer_size)
in - input stream of GZip filebuffer_size - input buffer size to usepublic static boolean isGzipped(ByteCountingPushBackInputStream pbin) throws java.io.IOException
PushBackInputStream for a GZip magic number.
The state of the PushBackInputStream is the same after the
call as before the call.pbin - PushBackInputStream with GZip entriesjava.io.IOException - if an I/O error occurs while examining head of streampublic void close() throws java.io.IOException
InputStream supplied to the constructor.close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOException - if an I/O error occurs while closing readerpublic boolean isCompliant()
public long getStartOffset()
public long getOffset()
public long getConsumed()
public GzipEntry getNextEntry() throws java.io.IOException
java.io.IOException - if an I/O error occurs while reading entryprotected byte[] readZeroTerminated() throws java.io.IOException
java.io.IOException - if an I/O error occurs while reading dataprotected void readTrailer(GzipEntry entry) throws java.io.IOException
entry - Gzip entryjava.io.IOException - if an I/O error occurs while reading dataprotected int readInflated(byte[] b, int off, int len) throws java.util.zip.DataFormatException, java.io.IOException
b - destination buffer for uncompressed dataoff - offset in bufferlen - length of uncompressed data to readjava.util.zip.DataFormatException - if the compressed data is in an unknown formatjava.io.IOException - if an I/O error occurs while reading dataCopyright © 2011–2023. All rights reserved.