Class BZip2CompressorInputStream
java.lang.Object
java.io.InputStream
org.jboss.shrinkwrap.impl.base.io.tar.bzip.BZip2CompressorInputStream
- All Implemented Interfaces:
Closeable, AutoCloseable
An input stream that decompresses from the BZip2 format to be read as any other stream.
Forked from Apache Commons-Compress with possible changes
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final int -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new BZip2CompressorInputStream which decompresses bytes read from the specified stream.BZip2CompressorInputStream(InputStream in, boolean decompressConcatenated) Constructs a new BZip2CompressorInputStream which decompresses bytes read from the specified stream. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()protected voidcount(int read) Increments the counter of already read bytes.protected voidcount(long read) Increments the counter of already read bytes.longReturns the current number of bytes read from this stream.intgetCount()Deprecated.this method may yield wrong results for large archives, use #getBytesRead insteadstatic booleanmatches(byte[] signature, int length) Checks if the signature matches what is expected for a bzip2 file.intread()intread(byte[] dest, int offs, int len) Methods inherited from class InputStream
available, mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, transferTo
-
Field Details
-
BASE_BLOCK_SIZE
static final int BASE_BLOCK_SIZE- See Also:
-
MAX_ALPHA_SIZE
static final int MAX_ALPHA_SIZE- See Also:
-
MAX_CODE_LEN
static final int MAX_CODE_LEN- See Also:
-
RUNA
static final int RUNA- See Also:
-
RUNB
static final int RUNB- See Also:
-
N_GROUPS
static final int N_GROUPS- See Also:
-
G_SIZE
static final int G_SIZE- See Also:
-
N_ITERS
static final int N_ITERS- See Also:
-
MAX_SELECTORS
static final int MAX_SELECTORS- See Also:
-
NUM_OVERSHOOT_BYTES
static final int NUM_OVERSHOOT_BYTES- See Also:
-
-
Constructor Details
-
BZip2CompressorInputStream
Constructs a new BZip2CompressorInputStream which decompresses bytes read from the specified stream. This doesn't support decompressing concatenated .bz2 files.- Throws:
IOException- if the stream content is malformed or an I/O error occurs.NullPointerException- if in == null
-
BZip2CompressorInputStream
public BZip2CompressorInputStream(InputStream in, boolean decompressConcatenated) throws IOException Constructs a new BZip2CompressorInputStream which decompresses bytes read from the specified stream.- Parameters:
in- the InputStream from which this object should be createddecompressConcatenated- if true, decompress until the end of the input; if false, stop after the first .bz2 stream and leave the input position to point to the next byte after the .bz2 stream- Throws:
IOException- if the stream content is malformed or an I/O error occurs.NullPointerException- if in == null
-
-
Method Details
-
count
protected void count(int read) Increments the counter of already read bytes. Doesn't increment if the EOF has been hit (read == -1)- Parameters:
read- the number of bytes read- Since:
- 1.1
-
count
protected void count(long read) Increments the counter of already read bytes. Doesn't increment if the EOF has been hit (read == -1)- Parameters:
read- the number of bytes read
-
getCount
Deprecated.this method may yield wrong results for large archives, use #getBytesRead insteadReturns the current number of bytes read from this stream.- Returns:
- the number of read bytes
-
getBytesRead
public long getBytesRead()Returns the current number of bytes read from this stream.- Returns:
- the number of read bytes
- Since:
- 1.1
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
matches
public static boolean matches(byte[] signature, int length) Checks if the signature matches what is expected for a bzip2 file.- Parameters:
signature- the bytes to checklength- the number of bytes to check- Returns:
- true, if this stream is a bzip2 compressed stream, false otherwise
- Since:
- 1.1
-