@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, compressorout| Constructor and Description | 
|---|
| BlockCompressorStream(OutputStream out,
                     Compressor compressor)Create a  BlockCompressorStreamwith 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, writeflush, getIOStatisticswritepublic 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 CompressorStreamIOExceptionpublic void finish()
            throws IOException
CompressionOutputStreamfinish in class CompressorStreamIOException - raised on errors performing I/O.protected void compress()
                 throws IOException
compress in class CompressorStreamIOExceptionCopyright © 2025 Apache Software Foundation. All rights reserved.