Class BZip2CompressorInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.apache.commons.compress.compressors.CompressorInputStream
-
- org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,InputStreamStatistics
public class BZip2CompressorInputStream extends CompressorInputStream implements InputStreamStatistics
An input stream that decompresses from the BZip2 format to be read as any other stream.
-
-
Field Summary
Fields Modifier and Type Field Description static intBASEBLOCKSIZEstatic intG_SIZEstatic intMAX_ALPHA_SIZEstatic intMAX_CODE_LENstatic intMAX_SELECTORSstatic intN_GROUPSstatic intN_ITERSstatic intNUM_OVERSHOOT_BYTESstatic intRUNAstatic intRUNB
-
Constructor Summary
Constructors Constructor Description BZip2CompressorInputStream(java.io.InputStream in)Constructs a new BZip2CompressorInputStream which decompresses bytes read from the specified stream.BZip2CompressorInputStream(java.io.InputStream in, boolean decompressConcatenated)Constructs a new BZip2CompressorInputStream which decompresses bytes read from the specified stream.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()longgetCompressedCount()static 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 org.apache.commons.compress.compressors.CompressorInputStream
getBytesRead, getCount, getUncompressedCount
-
Methods inherited from class java.io.InputStream
available, mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, transferTo
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.commons.compress.utils.InputStreamStatistics
getUncompressedCount
-
-
-
-
Field Detail
-
BASEBLOCKSIZE
public static final int BASEBLOCKSIZE
- See Also:
- Constant Field Values
-
MAX_ALPHA_SIZE
public static final int MAX_ALPHA_SIZE
- See Also:
- Constant Field Values
-
MAX_CODE_LEN
public static final int MAX_CODE_LEN
- See Also:
- Constant Field Values
-
RUNA
public static final int RUNA
- See Also:
- Constant Field Values
-
RUNB
public static final int RUNB
- See Also:
- Constant Field Values
-
N_GROUPS
public static final int N_GROUPS
- See Also:
- Constant Field Values
-
G_SIZE
public static final int G_SIZE
- See Also:
- Constant Field Values
-
N_ITERS
public static final int N_ITERS
- See Also:
- Constant Field Values
-
MAX_SELECTORS
public static final int MAX_SELECTORS
- See Also:
- Constant Field Values
-
NUM_OVERSHOOT_BYTES
public static final int NUM_OVERSHOOT_BYTES
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BZip2CompressorInputStream
public BZip2CompressorInputStream(java.io.InputStream in) throws java.io.IOExceptionConstructs a new BZip2CompressorInputStream which decompresses bytes read from the specified stream. This doesn't support decompressing concatenated .bz2 files.- Parameters:
in- the InputStream from which this object should be created- Throws:
java.io.IOException- if the stream content is malformed or an I/O error occurs.java.lang.NullPointerException- ifin == null
-
BZip2CompressorInputStream
public BZip2CompressorInputStream(java.io.InputStream in, boolean decompressConcatenated) throws java.io.IOExceptionConstructs 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:
java.io.IOException- ifin == null, the stream content is malformed, or an I/O error occurs.
-
-
Method Detail
-
read
public int read() throws java.io.IOException- Specified by:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
read
public int read(byte[] dest, int offs, int len) throws java.io.IOException- Overrides:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
getCompressedCount
public long getCompressedCount()
- Specified by:
getCompressedCountin interfaceInputStreamStatistics- Returns:
- the amount of raw or compressed bytes read by the stream
- Since:
- 1.17
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.InputStream- Throws:
java.io.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
-
-