public class LZFFileOutputStream
extends java.io.FileOutputStream
implements java.nio.channels.WritableByteChannel
FileOutputStream
.
Note that use of this class is not recommended unless you absolutely must
use a FileOutputStream
instance; otherwise basic LZFOutputStream
(which uses aggregation for underlying streams) is more appropriate
Implementation note: much of the code is just copied from LZFOutputStream
,
so care must be taken to keep implementations in sync if there are fixes.
Modifier and Type | Class and Description |
---|---|
private class |
LZFFileOutputStream.Wrapper
This simple wrapper is needed to re-route read calls so that they will
use "raw" writes
|
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 LZFFileOutputStream.Wrapper |
_wrapper
Wrapper object we use to allow decoder to write directly to the
stream, without ending in infinite loop...
|
private static int |
OUTPUT_BUFFER_SIZE |
Constructor and Description |
---|
LZFFileOutputStream(ChunkEncoder encoder,
java.io.File file) |
LZFFileOutputStream(ChunkEncoder encoder,
java.io.File file,
boolean append) |
LZFFileOutputStream(ChunkEncoder encoder,
java.io.File file,
boolean append,
BufferRecycler bufferRecycler) |
LZFFileOutputStream(ChunkEncoder encoder,
java.io.File file,
BufferRecycler bufferRecycler) |
LZFFileOutputStream(ChunkEncoder encoder,
java.io.FileDescriptor fdObj) |
LZFFileOutputStream(ChunkEncoder encoder,
java.io.FileDescriptor fdObj,
BufferRecycler bufferRecycler) |
LZFFileOutputStream(ChunkEncoder encoder,
java.lang.String name) |
LZFFileOutputStream(ChunkEncoder encoder,
java.lang.String name,
boolean append) |
LZFFileOutputStream(ChunkEncoder encoder,
java.lang.String name,
boolean append,
BufferRecycler bufferRecycler) |
LZFFileOutputStream(ChunkEncoder encoder,
java.lang.String name,
BufferRecycler bufferRecycler) |
LZFFileOutputStream(java.io.File file) |
LZFFileOutputStream(java.io.File file,
boolean append) |
LZFFileOutputStream(java.io.FileDescriptor fdObj) |
LZFFileOutputStream(java.lang.String name) |
LZFFileOutputStream(java.lang.String name,
boolean append) |
Modifier and Type | Method and Description |
---|---|
protected void |
checkNotClosed() |
void |
close() |
LZFFileOutputStream |
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
|
boolean |
isOpen() |
protected void |
rawWrite(byte[] buffer,
int offset,
int length) |
LZFFileOutputStream |
setFinishBlockOnFlush(boolean b)
Method for defining whether call to
flush() will also complete
current block (similar to calling finishBlock() ) or not. |
void |
write(byte[] b) |
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 b) |
protected void |
writeCompressedBlock()
Compress and write the current block to the OutputStream
|
private static final int 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
private final LZFFileOutputStream.Wrapper _wrapper
public LZFFileOutputStream(java.io.File file) throws java.io.FileNotFoundException
java.io.FileNotFoundException
public LZFFileOutputStream(java.io.File file, boolean append) throws java.io.FileNotFoundException
java.io.FileNotFoundException
public LZFFileOutputStream(java.io.FileDescriptor fdObj)
public LZFFileOutputStream(java.lang.String name) throws java.io.FileNotFoundException
java.io.FileNotFoundException
public LZFFileOutputStream(java.lang.String name, boolean append) throws java.io.FileNotFoundException
java.io.FileNotFoundException
public LZFFileOutputStream(ChunkEncoder encoder, java.io.File file) throws java.io.FileNotFoundException
java.io.FileNotFoundException
public LZFFileOutputStream(ChunkEncoder encoder, java.io.File file, boolean append) throws java.io.FileNotFoundException
java.io.FileNotFoundException
public LZFFileOutputStream(ChunkEncoder encoder, java.io.FileDescriptor fdObj)
public LZFFileOutputStream(ChunkEncoder encoder, java.lang.String name) throws java.io.FileNotFoundException
java.io.FileNotFoundException
public LZFFileOutputStream(ChunkEncoder encoder, java.lang.String name, boolean append) throws java.io.FileNotFoundException
java.io.FileNotFoundException
public LZFFileOutputStream(ChunkEncoder encoder, java.io.File file, BufferRecycler bufferRecycler) throws java.io.FileNotFoundException
java.io.FileNotFoundException
public LZFFileOutputStream(ChunkEncoder encoder, java.io.File file, boolean append, BufferRecycler bufferRecycler) throws java.io.FileNotFoundException
java.io.FileNotFoundException
public LZFFileOutputStream(ChunkEncoder encoder, java.io.FileDescriptor fdObj, BufferRecycler bufferRecycler)
public LZFFileOutputStream(ChunkEncoder encoder, java.lang.String name, BufferRecycler bufferRecycler) throws java.io.FileNotFoundException
java.io.FileNotFoundException
public LZFFileOutputStream(ChunkEncoder encoder, java.lang.String name, boolean append, BufferRecycler bufferRecycler) throws java.io.FileNotFoundException
java.io.FileNotFoundException
public LZFFileOutputStream setFinishBlockOnFlush(boolean b)
flush()
will also complete
current block (similar to calling finishBlock()
) or not.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.FileOutputStream
java.io.IOException
public void flush() throws java.io.IOException
flush
in interface java.io.Flushable
flush
in class java.io.OutputStream
java.io.IOException
public void write(byte[] b) throws java.io.IOException
write
in class java.io.FileOutputStream
java.io.IOException
public void write(byte[] buffer, int offset, int length) throws java.io.IOException
write
in class java.io.FileOutputStream
java.io.IOException
public void write(int b) throws java.io.IOException
write
in class java.io.FileOutputStream
java.io.IOException
public void write(java.io.InputStream 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 write(java.nio.channels.FileChannel in) throws java.io.IOException
java.io.IOException
public boolean getFinishBlockOnFlush()
public LZFFileOutputStream finishBlock() throws java.io.IOException
java.io.IOException
protected void writeCompressedBlock() throws java.io.IOException
java.io.IOException
protected void rawWrite(byte[] buffer, int offset, int length) throws java.io.IOException
java.io.IOException
protected void checkNotClosed() throws java.io.IOException
java.io.IOException