Class StreamCompressor
- java.lang.Object
 - 
- org.apache.commons.compress.archivers.zip.StreamCompressor
 
 
- 
- All Implemented Interfaces:
 java.io.Closeable,java.lang.AutoCloseable
public abstract class StreamCompressor extends java.lang.Object implements java.io.CloseableEncapsulates aDeflaterand crc calculator, handling multiple types of output streams. CurrentlyZipEntry.DEFLATEDandZipEntry.STOREDare the only supported compression methods.- Since:
 - 1.10
 
 
- 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()static StreamCompressorcreate(int compressionLevel, ScatterGatherBackingStore bs)Create a stream compressor with the given compression level.static StreamCompressorcreate(ScatterGatherBackingStore bs)Create a stream compressor with the default compression level.voiddeflate(java.io.InputStream source, int method)Deflate the given source using the supplied compression methodlonggetBytesRead()Return the number of bytes read from the source streamlonggetBytesWrittenForLastEntry()The number of bytes written to the output for the last entrylonggetCrc32()The crc32 of the last deflated filelonggetTotalBytesWritten()The total number of bytes written to the output for all filesvoidwriteCounted(byte[] data)voidwriteCounted(byte[] data, int offset, int length) 
 - 
 
- 
- 
Method Detail
- 
create
public static StreamCompressor create(int compressionLevel, ScatterGatherBackingStore bs)
Create a stream compressor with the given compression level.- Parameters:
 compressionLevel- TheDeflatercompression levelbs- The ScatterGatherBackingStore to receive output- Returns:
 - A stream compressor
 
 
- 
create
public static StreamCompressor create(ScatterGatherBackingStore bs)
Create a stream compressor with the default compression level.- Parameters:
 bs- The ScatterGatherBackingStore to receive output- Returns:
 - A stream compressor
 
 
- 
getCrc32
public long getCrc32()
The crc32 of the last deflated file- Returns:
 - the crc32
 
 
- 
getBytesRead
public long getBytesRead()
Return the number of bytes read from the source stream- Returns:
 - The number of bytes read, never negative
 
 
- 
getBytesWrittenForLastEntry
public long getBytesWrittenForLastEntry()
The number of bytes written to the output for the last entry- Returns:
 - The number of bytes, never negative
 
 
- 
getTotalBytesWritten
public long getTotalBytesWritten()
The total number of bytes written to the output for all files- Returns:
 - The number of bytes, never negative
 
 
- 
deflate
public void deflate(java.io.InputStream source, int method) throws java.io.IOExceptionDeflate the given source using the supplied compression method- Parameters:
 source- The source to compressmethod- The #ZipArchiveEntry compression method- Throws:
 java.io.IOException- When failures happen
 
- 
close
public void close() throws java.io.IOException- Specified by:
 closein interfacejava.lang.AutoCloseable- Specified by:
 closein interfacejava.io.Closeable- Throws:
 java.io.IOException
 
- 
writeCounted
public void writeCounted(byte[] data) throws java.io.IOException- Throws:
 java.io.IOException
 
- 
writeCounted
public void writeCounted(byte[] data, int offset, int length) throws java.io.IOException- Throws:
 java.io.IOException
 
 - 
 
 -