org.apache.commons.compress.compressors.gzip
public class GzipCompressorInputStream extends CompressorInputStream
GZIPInputStream
doesn't decompress concatenated .gz
files: it stops after the first member and silently ignores the rest.
It doesn't leave the read position to point to the beginning of the next
member, which makes it difficult workaround the lack of concatenation
support.
Instead of using GZIPInputStream
, this class has its own .gz
container format decoder. The actual decompression is done with
Inflater
.
Constructor and Description |
---|
GzipCompressorInputStream(InputStream inputStream)
Constructs a new input stream that decompresses gzip-compressed data
from the specified input stream.
|
GzipCompressorInputStream(InputStream inputStream,
boolean decompressConcatenated)
Constructs a new input stream that decompresses gzip-compressed data
from the specified input stream.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the input stream (unless it is System.in).
|
GzipParameters |
getMetaData()
Provides the stream's meta data - may change with each stream
when decompressing concatenated streams.
|
static boolean |
matches(byte[] signature,
int length)
Checks if the signature matches what is expected for a .gz file.
|
int |
read() |
int |
read(byte[] b,
int off,
int len) |
count, count, getBytesRead, getCount, pushedBackBytes
available, mark, markSupported, read, reset, skip
public GzipCompressorInputStream(InputStream inputStream) throws IOException
This is equivalent to
GzipCompressorInputStream(inputStream, false)
and thus
will not decompress concatenated .gz files.
inputStream
- the InputStream from which this object should
be created ofIOException
- if the stream could not be createdpublic GzipCompressorInputStream(InputStream inputStream, boolean decompressConcatenated) throws IOException
If decompressConcatenated
is false
:
This decompressor might read more input than it will actually use.
If inputStream
supports mark
and
reset
, then the input position will be adjusted
so that it is right after the last byte of the compressed stream.
If mark
isn't supported, the input position will be
undefined.
inputStream
- the InputStream from which this object should
be created ofdecompressConcatenated
- if true, decompress until the end of the input;
if false, stop after the first .gz memberIOException
- if the stream could not be createdpublic GzipParameters getMetaData()
public int read() throws IOException
read
in class InputStream
IOException
public int read(byte[] b, int off, int len) throws IOException
read
in class InputStream
IOException
public static boolean matches(byte[] signature, int length)
signature
- the bytes to checklength
- the number of bytes to checkpublic void close() throws IOException
close
in interface Closeable
close
in class InputStream
IOException
Copyright © 2014 The Apache Software Foundation. All rights reserved.