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.AbstractCompressorImplementation of the Compressor Interface for BZip2.- Author:
- christian.grobmeier
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringDEFAULT_FILE_EXTENSIONprivate static byte[]HEADERprivate static java.lang.StringNAME
-
Constructor Summary
Constructors Constructor Description BZip2Compressor()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcompressTo(java.io.InputStream in, java.io.OutputStream out)Compresses the input stream and writes the compressed bytes to the output stream.voiddecompressTo(java.io.InputStream in, java.io.OutputStream out)Decompresses this file and writes the decompressed file to the output-streamjava.lang.StringgetDefaultFileExtension()Returns a String with the default file extension for this compressor.byte[]getHeader()Header byte array for this archive.java.lang.StringgetName()Returns the ArchiveName for this archive.private BZip2InputStreamgetPackedInput(java.io.InputStream input)Skips the 'BZ' header bytes.private BZip2OutputStreamgetPackedOutput(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.CompressExceptionDescription copied from interface:org.apache.commons.compress.CompressorCompresses 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.CompressExceptionDescription copied from interface:org.apache.commons.compress.CompressorDecompresses 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:
BZip2InputStreaminstance- 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-OutputStreamto add a header to- Returns:
BZip2OutputStreamready to write to- Throws:
java.io.IOException- if an IO error occurs
-
getHeader
public byte[] getHeader()
Description copied from class:org.apache.commons.compress.PackableObjectHeader byte array for this archive.- Specified by:
getHeaderin classorg.apache.commons.compress.PackableObject
-
getName
public java.lang.String getName()
Description copied from class:org.apache.commons.compress.PackableObjectReturns the ArchiveName for this archive.- Specified by:
getNamein classorg.apache.commons.compress.PackableObject
-
getDefaultFileExtension
public java.lang.String getDefaultFileExtension()
Description copied from class:org.apache.commons.compress.AbstractCompressorReturns 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:
getDefaultFileExtensionin classorg.apache.commons.compress.AbstractCompressor- Returns:
- the default file extension
-
-