public abstract class StreamCompressor extends Object implements Closeable
Deflater and crc calculator, handling multiple types of output streams.
Currently ZipEntry.DEFLATED and ZipEntry.STORED are the only
supported compression methods.| Modifier and Type | Method and Description |
|---|---|
void |
close() |
static StreamCompressor |
create(int compressionLevel,
ScatterGatherBackingStore bs)
Create a stream compressor with the given compression level.
|
static StreamCompressor |
create(ScatterGatherBackingStore bs)
Create a stream compressor with the default compression level.
|
void |
deflate(InputStream source,
int method)
Deflate the given source using the supplied compression method
|
long |
getBytesRead()
Return the number of bytes read from the source stream
|
long |
getBytesWrittenForLastEntry()
The number of bytes written to the output for the last entry
|
long |
getCrc32()
The crc32 of the last deflated file
|
long |
getTotalBytesWritten()
The total number of bytes written to the output for all files
|
void |
writeCounted(byte[] data) |
void |
writeCounted(byte[] data,
int offset,
int length) |
protected abstract void |
writeOut(byte[] data,
int offset,
int length) |
public static StreamCompressor create(int compressionLevel, ScatterGatherBackingStore bs)
compressionLevel - The Deflater compression levelbs - The ScatterGatherBackingStore to receive outputpublic static StreamCompressor create(ScatterGatherBackingStore bs)
bs - The ScatterGatherBackingStore to receive outputpublic long getCrc32()
public long getBytesRead()
public long getBytesWrittenForLastEntry()
public long getTotalBytesWritten()
public void deflate(InputStream source, int method) throws IOException
source - The source to compressmethod - The #ZipArchiveEntry compression methodIOException - When failures happenpublic void close() throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic void writeCounted(byte[] data) throws IOException
IOExceptionpublic void writeCounted(byte[] data, int offset, int length) throws IOException
IOExceptionprotected abstract void writeOut(byte[] data, int offset, int length) throws IOException
IOExceptionCopyright © 2018 The Apache Software Foundation. All rights reserved.