Class BZip2Compressor
- java.lang.Object
-
- org.apache.commons.compress.PackableObject
-
- org.apache.commons.compress.AbstractCompressor
-
- org.apache.commons.compress.compressors.bzip2.BZip2Compressor
-
- All Implemented Interfaces:
org.apache.commons.compress.Compressor
public class BZip2Compressor extends org.apache.commons.compress.AbstractCompressor
Implementation of the Compressor Interface for BZip2.- Author:
- christian.grobmeier
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
DEFAULT_FILE_EXTENSION
private static byte[]
HEADER
private static java.lang.String
NAME
-
Constructor Summary
Constructors Constructor Description BZip2Compressor()
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
compressTo(java.io.InputStream in, java.io.OutputStream out)
Compresses the input stream and writes the compressed bytes to the output stream.void
decompressTo(java.io.InputStream in, java.io.OutputStream out)
Decompresses this file and writes the decompressed file to the output-streamjava.lang.String
getDefaultFileExtension()
Returns a String with the default file extension for this compressor.byte[]
getHeader()
Header byte array for this archive.java.lang.String
getName()
Returns the ArchiveName for this archive.private BZip2InputStream
getPackedInput(java.io.InputStream input)
Skips the 'BZ' header bytes.private BZip2OutputStream
getPackedOutput(java.io.OutputStream output)
Writes a 'BZ' header to the output stream, and creates a BZip2OutputStream object ready for use, as required by the BZip2OutputStream class.-
Methods inherited from class org.apache.commons.compress.AbstractCompressor
compress, compress, compressTo, compressToHere, decompress, decompress, decompressTo
-
-
-
-
Field Detail
-
HEADER
private static final byte[] HEADER
-
NAME
private static final java.lang.String NAME
- See Also:
- Constant Field Values
-
DEFAULT_FILE_EXTENSION
private static java.lang.String DEFAULT_FILE_EXTENSION
-
-
Method Detail
-
compressTo
public void compressTo(java.io.InputStream in, java.io.OutputStream out) throws org.apache.commons.compress.CompressException
Description copied from interface:org.apache.commons.compress.Compressor
Compresses the input stream and writes the compressed bytes to the output stream. This method must be implemented by all new compressortypes.- Parameters:
in
- InputStream to compress toout
- OutputStream to which the byte shall be written- Throws:
org.apache.commons.compress.CompressException
- if the Compressor reports an error
-
decompressTo
public void decompressTo(java.io.InputStream in, java.io.OutputStream out) throws org.apache.commons.compress.CompressException
Description copied from interface:org.apache.commons.compress.Compressor
Decompresses this file and writes the decompressed file to the output-stream- Parameters:
in
- Stream to decompressout
- Stream to write the decompressed bytes to- Throws:
org.apache.commons.compress.CompressException
- if the Compressor reports an error
-
getPackedInput
private BZip2InputStream getPackedInput(java.io.InputStream input) throws java.io.IOException
Skips the 'BZ' header bytes. required by the BZip2InputStream class.- Parameters:
input
- input stream- Returns:
BZip2InputStream
instance- Throws:
java.io.IOException
- if an IO error occurs
-
getPackedOutput
private BZip2OutputStream getPackedOutput(java.io.OutputStream output) throws java.io.IOException
Writes a 'BZ' header to the output stream, and creates a BZip2OutputStream object ready for use, as required by the BZip2OutputStream class.- Parameters:
output
-OutputStream
to add a header to- Returns:
BZip2OutputStream
ready to write to- Throws:
java.io.IOException
- if an IO error occurs
-
getHeader
public byte[] getHeader()
Description copied from class:org.apache.commons.compress.PackableObject
Header byte array for this archive.- Specified by:
getHeader
in classorg.apache.commons.compress.PackableObject
-
getName
public java.lang.String getName()
Description copied from class:org.apache.commons.compress.PackableObject
Returns the ArchiveName for this archive.- Specified by:
getName
in classorg.apache.commons.compress.PackableObject
-
getDefaultFileExtension
public java.lang.String getDefaultFileExtension()
Description copied from class:org.apache.commons.compress.AbstractCompressor
Returns a String with the default file extension for this compressor. For example, a zip-files default file extension would be "zip" (without leading dot).- Specified by:
getDefaultFileExtension
in classorg.apache.commons.compress.AbstractCompressor
- Returns:
- the default file extension
-
-