@InterfaceAudience.Public @InterfaceStability.Evolving public class BlockCompressorStream extends CompressorStream
CompressorStream
which works
with 'block-based' based compression algorithms, as opposed to
'stream-based' compression algorithms.
It should be noted that this wrapper does not guarantee that blocks will
be sized for the compressor. If the
Compressor
requires buffering to
effect meaningful compression, it is responsible for it.buffer, closed, compressor
out
Constructor and Description |
---|
BlockCompressorStream(OutputStream out,
Compressor compressor)
Create a
BlockCompressorStream with given output-stream and
compressor. |
BlockCompressorStream(OutputStream out,
Compressor compressor,
int bufferSize,
int compressionOverhead)
Create a
BlockCompressorStream . |
Modifier and Type | Method and Description |
---|---|
protected void |
compress() |
void |
finish()
Finishes writing compressed data to the output stream
without closing the underlying stream.
|
void |
write(byte[] b,
int off,
int len)
Write the data provided to the compression codec, compressing no more
than the buffer size less the compression overhead as specified during
construction for each block.
|
close, resetState, write
flush
write
public BlockCompressorStream(OutputStream out, Compressor compressor, int bufferSize, int compressionOverhead)
BlockCompressorStream
.out
- streamcompressor
- compressor to be usedbufferSize
- size of buffercompressionOverhead
- maximum 'overhead' of the compression
algorithm with given bufferSizepublic BlockCompressorStream(OutputStream out, Compressor compressor)
BlockCompressorStream
with given output-stream and
compressor.
Use default of 512 as bufferSize and compressionOverhead of
(1% of bufferSize + 12 bytes) = 18 bytes (zlib algorithm).out
- streamcompressor
- compressor to be usedpublic void write(byte[] b, int off, int len) throws IOException
write
in class CompressorStream
IOException
public void finish() throws IOException
CompressionOutputStream
finish
in class CompressorStream
IOException
protected void compress() throws IOException
compress
in class CompressorStream
IOException
Copyright © 2017 Apache Software Foundation. All Rights Reserved.