public class LZFFileInputStream extends FileInputStream
FileInputStream
.
Note that use of this class is not recommended unless you absolutely must
use a FileInputStream
instance; otherwise basic LZFInputStream
(which uses aggregation for underlying streams) is more appropriate
Implementation note: much of the code is just copied from LZFInputStream
,
so care must be taken to keep implementations in sync if there are fixes.
Modifier and Type | Field and Description |
---|---|
protected int |
_bufferLength
Length of the current uncompressed bytes buffer
|
protected int |
_bufferPosition
The current position (next char to output) in the uncompressed bytes buffer.
|
protected boolean |
_cfgFullReads
Flag that indicates whether we force full reads (reading of as many
bytes as requested), or 'optimal' reads (up to as many as available,
but at least one).
|
protected byte[] |
_decodedBytes
the buffer of uncompressed bytes from which content is read
|
protected ChunkDecoder |
_decompressor
Underlying decoder in use.
|
protected byte[] |
_inputBuffer
the current buffer of compressed bytes (from which to decode)
|
protected boolean |
_inputStreamClosed
Flag that indicates if we have already called 'inputStream.close()'
(to avoid calling it multiple times)
|
protected BufferRecycler |
_recycler
Object that handles details of buffer recycling
|
protected com.ning.compress.lzf.util.LZFFileInputStream.Wrapper |
_wrapper
Wrapper object we use to allow decoder to read directly from the
stream, without ending in infinite loop...
|
Constructor and Description |
---|
LZFFileInputStream(File file) |
LZFFileInputStream(File file,
ChunkDecoder decompressor) |
LZFFileInputStream(File file,
ChunkDecoder decompressor,
BufferRecycler bufferRecycler) |
LZFFileInputStream(FileDescriptor fdObj) |
LZFFileInputStream(FileDescriptor fdObj,
ChunkDecoder decompressor) |
LZFFileInputStream(FileDescriptor fdObj,
ChunkDecoder decompressor,
BufferRecycler bufferRecycler) |
LZFFileInputStream(String name) |
LZFFileInputStream(String name,
ChunkDecoder decompressor) |
LZFFileInputStream(String name,
ChunkDecoder decompressor,
BufferRecycler bufferRecycler) |
Modifier and Type | Method and Description |
---|---|
int |
available() |
void |
close() |
int |
read() |
int |
read(byte[] b) |
int |
read(byte[] buffer,
int offset,
int length) |
int |
readAndWrite(OutputStream out)
Convenience method that will read and uncompress all data available,
and write it using given
OutputStream . |
protected int |
readRaw(byte[] buffer,
int offset,
int length) |
protected boolean |
readyBuffer()
Fill the uncompressed bytes buffer by reading the underlying inputStream.
|
void |
setUseFullReads(boolean b)
Method that can be used define whether reads should be "full" or
"optimal": former means that full compressed blocks are read right
away as needed, optimal that only smaller chunks are read at a time,
more being read as needed.
|
long |
skip(long n)
Overridden to implement efficient skipping by skipping full chunks whenever
possible.
|
protected long |
skipRaw(long amount) |
finalize, getChannel, getFD
mark, markSupported, reset
protected final ChunkDecoder _decompressor
protected final BufferRecycler _recycler
protected boolean _inputStreamClosed
protected boolean _cfgFullReads
protected byte[] _inputBuffer
protected byte[] _decodedBytes
protected int _bufferPosition
protected int _bufferLength
protected final com.ning.compress.lzf.util.LZFFileInputStream.Wrapper _wrapper
public LZFFileInputStream(File file) throws FileNotFoundException
FileNotFoundException
public LZFFileInputStream(FileDescriptor fdObj)
public LZFFileInputStream(String name) throws FileNotFoundException
FileNotFoundException
public LZFFileInputStream(File file, ChunkDecoder decompressor) throws FileNotFoundException
FileNotFoundException
public LZFFileInputStream(FileDescriptor fdObj, ChunkDecoder decompressor)
public LZFFileInputStream(String name, ChunkDecoder decompressor) throws FileNotFoundException
FileNotFoundException
public LZFFileInputStream(File file, ChunkDecoder decompressor, BufferRecycler bufferRecycler) throws FileNotFoundException
FileNotFoundException
public LZFFileInputStream(FileDescriptor fdObj, ChunkDecoder decompressor, BufferRecycler bufferRecycler)
public LZFFileInputStream(String name, ChunkDecoder decompressor, BufferRecycler bufferRecycler) throws FileNotFoundException
FileNotFoundException
public void setUseFullReads(boolean b)
public int available()
available
in class FileInputStream
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class FileInputStream
IOException
public int read() throws IOException
read
in class FileInputStream
IOException
public int read(byte[] b) throws IOException
read
in class FileInputStream
IOException
public int read(byte[] buffer, int offset, int length) throws IOException
read
in class FileInputStream
IOException
public long skip(long n) throws IOException
skip
in class FileInputStream
IOException
public int readAndWrite(OutputStream out) throws IOException
OutputStream
. This avoids having to
make an intermediate copy of uncompressed data which would be needed
when doing the same manually.out
- OutputStream to use for writing contentIOException
protected boolean readyBuffer() throws IOException
IOException
protected final int readRaw(byte[] buffer, int offset, int length) throws IOException
IOException
protected final long skipRaw(long amount) throws IOException
IOException
Copyright © 2017. All Rights Reserved.