Package com.ning.compress.lzf
Class LZFOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
com.ning.compress.lzf.LZFOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
,Channel
,WritableByteChannel
Decorator
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.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
Configuration setting that governs whether basic 'flush()' should first complete a block or not.private final ChunkEncoder
protected byte[]
protected boolean
Flag that indicates if we have already called '_outputStream.close()' (to avoid calling it multiple times)protected int
private final BufferRecycler
private static final int
Fields inherited from class java.io.FilterOutputStream
out
-
Constructor Summary
ConstructorsConstructorDescriptionLZFOutputStream
(ChunkEncoder encoder, OutputStream outputStream) LZFOutputStream
(ChunkEncoder encoder, OutputStream outputStream, int bufferSize, BufferRecycler bufferRecycler) LZFOutputStream
(ChunkEncoder encoder, OutputStream outputStream, BufferRecycler bufferRecycler) LZFOutputStream
(OutputStream outputStream) LZFOutputStream
(OutputStream outputStream, BufferRecycler bufferRecycler) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
void
close()
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
Accessor for checking whether call to "flush()" will first finish the current block or not.Method that can be used to find underlyingOutputStream
that we write encoded LZF encoded data into, after compressing it.boolean
isOpen()
setFinishBlockOnFlush
(boolean b) Method for defining whether call toflush()
will also complete current block (similar to callingfinishBlock()
) or not.void
write
(byte[] buffer, int offset, int length) void
write
(int singleByte) void
write
(InputStream in) int
write
(ByteBuffer src) void
write
(FileChannel in) protected void
Compress and write the current block to the OutputStreamMethods inherited from class java.io.FilterOutputStream
write
Methods inherited from class java.io.OutputStream
nullOutputStream
-
Field Details
-
DEFAULT_OUTPUT_BUFFER_SIZE
private static final int DEFAULT_OUTPUT_BUFFER_SIZE- See Also:
-
_encoder
-
_recycler
-
_outputBuffer
protected byte[] _outputBuffer -
_position
protected int _position -
_cfgFinishBlockOnFlush
protected boolean _cfgFinishBlockOnFlushConfiguration setting that governs whether basic 'flush()' should first complete a block or not.Default value is 'true'
-
_outputStreamClosed
protected boolean _outputStreamClosedFlag that indicates if we have already called '_outputStream.close()' (to avoid calling it multiple times)
-
-
Constructor Details
-
LZFOutputStream
-
LZFOutputStream
-
LZFOutputStream
-
LZFOutputStream
public LZFOutputStream(ChunkEncoder encoder, OutputStream outputStream, BufferRecycler bufferRecycler) -
LZFOutputStream
public LZFOutputStream(ChunkEncoder encoder, OutputStream outputStream, int bufferSize, BufferRecycler bufferRecycler)
-
-
Method Details
-
setFinishBlockOnFlush
Method for defining whether call toflush()
will also complete current block (similar to callingfinishBlock()
) or not. -
write
- Overrides:
write
in classFilterOutputStream
- Throws:
IOException
-
write
- Overrides:
write
in classFilterOutputStream
- Throws:
IOException
-
write
- Throws:
IOException
-
write
- Throws:
IOException
-
write
- Specified by:
write
in interfaceWritableByteChannel
- Throws:
IOException
-
flush
- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classFilterOutputStream
- Throws:
IOException
-
isOpen
public boolean isOpen() -
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceChannel
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classFilterOutputStream
- Throws:
IOException
-
getUnderlyingOutputStream
Method that can be used to find underlyingOutputStream
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). -
getFinishBlockOnFlush
public boolean getFinishBlockOnFlush()Accessor for checking whether call to "flush()" will first finish the current block or not. -
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. This typically results in lower compression ratio as larger blocks compress better; but may be necessary for network connections to ensure timely sending of data.- Throws:
IOException
-
writeCompressedBlock
Compress and write the current block to the OutputStream- Throws:
IOException
-
checkNotClosed
- Throws:
IOException
-