public class Bzip2Compressor
extends java.lang.Object
Compressor
for BZip2 streams.
Due to historical reasons (we used to use the ant-tools bz2 libraries,
rather than commons-compress) the compressed streams **DO NOT** have the
standard "BZ" header.Compressor.COMPRESSOR_TYPE
Modifier and Type | Field and Description |
---|---|
static byte[] |
BZ_HEADER |
DEFAULT_COMPRESSORDESCRIPTOR
Constructor and Description |
---|
Bzip2Compressor() |
Modifier and Type | Method and Description |
---|---|
Bucket |
compress(Bucket data,
BucketFactory bf,
long maxReadLength,
long maxWriteLength)
Compress the data.
|
long |
compress(java.io.InputStream input,
java.io.OutputStream output,
long maxReadLength,
long maxWriteLength)
Compress the data.
|
long |
compress(java.io.InputStream is,
java.io.OutputStream os,
long maxReadLength,
long maxWriteLength,
long amountOfDataToCheckCompressionRatio,
int minimumCompressionPercentage)
Compress the data (@see
Compressor.compress(InputStream, OutputStream, long, long) ) with checking of compression effect. |
int |
decompress(byte[] dbuf,
int i,
int j,
byte[] output)
Decompress in RAM only.
|
long |
decompress(java.io.InputStream is,
java.io.OutputStream os,
long maxLength,
long maxCheckSizeBytes)
Decompress data.
|
public Bucket compress(Bucket data, BucketFactory bf, long maxReadLength, long maxWriteLength) throws java.io.IOException, CompressionOutputSizeException
Compressor
data
- The bucket to read from.bf
- The means to create a new bucket.maxReadLength
- The maximum number of bytes to read from the input bucket.maxWriteLength
- The maximum number of bytes to write to the output bucket. If this is exceeded, throw a CompressionOutputSizeException.java.io.IOException
- If an error occurs reading or writing data.CompressionOutputSizeException
- If the compressed data is larger than maxWriteLength.public long compress(java.io.InputStream is, java.io.OutputStream os, long maxReadLength, long maxWriteLength, long amountOfDataToCheckCompressionRatio, int minimumCompressionPercentage) throws java.io.IOException, CompressionRatioException
Compressor
Compressor.compress(InputStream, OutputStream, long, long)
) with checking of compression effect.amountOfDataToCheckCompressionRatio
- The data amount after compression of which we will check whether we have got the desired effect.minimumCompressionPercentage
- The minimal desired compression effect, %. A value of 0 means that the
compression effect will not be checked.CompressionRatioException
- If the desired compression effect is not achieved.java.io.IOException
public long decompress(java.io.InputStream is, java.io.OutputStream os, long maxLength, long maxCheckSizeBytes) throws java.io.IOException, CompressionOutputSizeException
Compressor
is
- Where to read the data to decompress fromos
- Where to write the final product tomaxLength
- The maximum length to decompress (we throw if more is present).maxCheckSizeBytes
- If the data is too big, and this is >0, read up to this many bytes in order to try to get the data size.java.io.IOException
CompressionOutputSizeException
public int decompress(byte[] dbuf, int i, int j, byte[] output) throws CompressionOutputSizeException
Compressor
dbuf
- Input buffer.i
- Offset to start reading from.j
- Number of bytes to read.output
- Output buffer.CompressionOutputSizeException
public long compress(java.io.InputStream input, java.io.OutputStream output, long maxReadLength, long maxWriteLength) throws java.io.IOException
Compressor
compress
in interface Compressor
input
- The InputStream to read from.output
- The OutputStream to write to.maxReadLength
- The maximum number of bytes to read from the input bucket.maxWriteLength
- The maximum number of bytes to write to the output bucket. If this is exceeded, throw a CompressionOutputSizeException.java.io.IOException
- If an error occurs reading or writing data.CompressionOutputSizeException
- If the compressed data is larger than maxWriteLength.