public class LZFOutputStream
extends java.io.FilterOutputStream
implements java.nio.channels.WritableByteChannel
OutputStream
implementation that will compress
output using LZF compression algorithm, given uncompressed input
to write. Its counterpart is LZFInputStream
; although
in some ways LZFCompressingInputStream
can be seen
as the opposite.LZFInputStream
,
LZFCompressingInputStream
Modifier and Type | Field and Description |
---|---|
protected boolean |
_cfgFinishBlockOnFlush
Configuration setting that governs whether basic 'flush()' should
first complete a block or not.
|
private ChunkEncoder |
_encoder |
protected byte[] |
_outputBuffer |
protected boolean |
_outputStreamClosed
Flag that indicates if we have already called '_outputStream.close()'
(to avoid calling it multiple times)
|
protected int |
_position |
private BufferRecycler |
_recycler |
private static int |
DEFAULT_OUTPUT_BUFFER_SIZE |
Constructor and Description |
---|
LZFOutputStream(ChunkEncoder encoder,
java.io.OutputStream outputStream) |
LZFOutputStream(ChunkEncoder encoder,
java.io.OutputStream outputStream,
BufferRecycler bufferRecycler) |
LZFOutputStream(ChunkEncoder encoder,
java.io.OutputStream outputStream,
int bufferSize,
BufferRecycler bufferRecycler) |
LZFOutputStream(java.io.OutputStream outputStream) |
LZFOutputStream(java.io.OutputStream outputStream,
BufferRecycler bufferRecycler) |
Modifier and Type | Method and Description |
---|---|
protected void |
checkNotClosed() |
void |
close() |
LZFOutputStream |
finishBlock()
Method that can be used to force completion of the current block,
which means that all buffered data will be compressed into an
LZF block.
|
void |
flush() |
boolean |
getFinishBlockOnFlush()
Accessor for checking whether call to "flush()" will first finish the
current block or not.
|
java.io.OutputStream |
getUnderlyingOutputStream()
Method that can be used to find underlying
OutputStream that
we write encoded LZF encoded data into, after compressing it. |
boolean |
isOpen() |
LZFOutputStream |
setFinishBlockOnFlush(boolean b)
Method for defining whether call to
flush() will also complete
current block (similar to calling finishBlock() ) or not. |
void |
write(byte[] buffer,
int offset,
int length) |
int |
write(java.nio.ByteBuffer src) |
void |
write(java.nio.channels.FileChannel in) |
void |
write(java.io.InputStream in) |
void |
write(int singleByte) |
protected void |
writeCompressedBlock()
Compress and write the current block to the OutputStream
|
private static final int DEFAULT_OUTPUT_BUFFER_SIZE
private final ChunkEncoder _encoder
private final BufferRecycler _recycler
protected byte[] _outputBuffer
protected int _position
protected boolean _cfgFinishBlockOnFlush
Default value is 'true'
protected boolean _outputStreamClosed
public LZFOutputStream(java.io.OutputStream outputStream)
public LZFOutputStream(ChunkEncoder encoder, java.io.OutputStream outputStream)
public LZFOutputStream(java.io.OutputStream outputStream, BufferRecycler bufferRecycler)
public LZFOutputStream(ChunkEncoder encoder, java.io.OutputStream outputStream, BufferRecycler bufferRecycler)
public LZFOutputStream(ChunkEncoder encoder, java.io.OutputStream outputStream, int bufferSize, BufferRecycler bufferRecycler)
public LZFOutputStream setFinishBlockOnFlush(boolean b)
flush()
will also complete
current block (similar to calling finishBlock()
) or not.public void write(int singleByte) throws java.io.IOException
write
in class java.io.FilterOutputStream
java.io.IOException
public void write(byte[] buffer, int offset, int length) throws java.io.IOException
write
in class java.io.FilterOutputStream
java.io.IOException
public void write(java.io.InputStream in) throws java.io.IOException
java.io.IOException
public void write(java.nio.channels.FileChannel in) throws java.io.IOException
java.io.IOException
public int write(java.nio.ByteBuffer src) throws java.io.IOException
write
in interface java.nio.channels.WritableByteChannel
java.io.IOException
public void flush() throws java.io.IOException
flush
in interface java.io.Flushable
flush
in class java.io.FilterOutputStream
java.io.IOException
public boolean isOpen()
isOpen
in interface java.nio.channels.Channel
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in interface java.nio.channels.Channel
close
in class java.io.FilterOutputStream
java.io.IOException
public java.io.OutputStream getUnderlyingOutputStream()
OutputStream
that
we write encoded LZF encoded data into, after compressing it.
Will never return null; although underlying stream may be closed
(if this stream has been closed).public boolean getFinishBlockOnFlush()
public LZFOutputStream finishBlock() throws java.io.IOException
java.io.IOException
protected void writeCompressedBlock() throws java.io.IOException
java.io.IOException
protected void checkNotClosed() throws java.io.IOException
java.io.IOException