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 | Class and Description |
|---|---|
| private class | LZFFileInputStream.Wrapper
This simple wrapper is needed to re-route read calls so that they will use "raw" reads |
| 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 final 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 final BufferRecycler | _recycler
Object that handles details of buffer recycling |
| protected final LZFFileInputStream. | _wrapper
Wrapper object we use to allow decoder to read directly from the stream, without ending in infinite loop... |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| public | |
| public | |
| public | |
| public | |
| public | |
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public int | available()
Overrides java. |
| public void | close()
Overrides java. Implements java. |
| public int | |
| public int | read(byte[]
the buffer into which the data is read. b)Overrides java. b.length bytes of data from this input
stream into an array of bytes.
|
| public int | read(byte[]
the buffer into which the data is read. buffer, int the start offset in array offset, int b
at which the data is written.the maximum number of bytes to read. length)Overrides java. len bytes of data from this input stream
into an array of bytes.
|
| public int | Returns: Number of bytes written (uncompressed)OutputStream to use for writing content out)Convenience method that will read and uncompress all data available,
and write it using given |
| protected final int | |
| protected boolean | |
| public 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. |
| public long | skip(long
the number of bytes to be skipped. n)Overrides java. |
| protected final long |
| _bufferLength | back to summary |
|---|---|
| protected int _bufferLength Length of the current uncompressed bytes buffer | |
| _bufferPosition | back to summary |
|---|---|
| protected int _bufferPosition The current position (next char to output) in the uncompressed bytes buffer. | |
| _cfgFullReads | back to summary |
|---|---|
| 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). Default is false, meaning that 'optimal' read is used. | |
| _decodedBytes | back to summary |
|---|---|
| protected byte[] _decodedBytes the buffer of uncompressed bytes from which content is read | |
| _decompressor | back to summary |
|---|---|
| protected final ChunkDecoder _decompressor Underlying decoder in use. | |
| _inputBuffer | back to summary |
|---|---|
| protected byte[] _inputBuffer the current buffer of compressed bytes (from which to decode) | |
| _inputStreamClosed | back to summary |
|---|---|
| protected boolean _inputStreamClosed Flag that indicates if we have already called 'inputStream.close()' (to avoid calling it multiple times) | |
| _recycler | back to summary |
|---|---|
| protected final BufferRecycler _recycler Object that handles details of buffer recycling | |
| _wrapper | back to summary |
|---|---|
| protected final LZFFileInputStream. Wrapper object we use to allow decoder to read directly from the stream, without ending in infinite loop... | |
| LZFFileInputStream | back to summary |
|---|---|
| public LZFFileInputStream(File file) throws FileNotFoundException | |
| LZFFileInputStream | back to summary |
|---|---|
| public LZFFileInputStream(FileDescriptor fdObj) | |
| LZFFileInputStream | back to summary |
|---|---|
| public LZFFileInputStream(String name) throws FileNotFoundException | |
| LZFFileInputStream | back to summary |
|---|---|
| public LZFFileInputStream(File file, ChunkDecoder decompressor) throws FileNotFoundException | |
| LZFFileInputStream | back to summary |
|---|---|
| public LZFFileInputStream(FileDescriptor fdObj, ChunkDecoder decompressor) | |
| LZFFileInputStream | back to summary |
|---|---|
| public LZFFileInputStream(String name, ChunkDecoder decompressor) throws FileNotFoundException | |
| LZFFileInputStream | back to summary |
|---|---|
| public LZFFileInputStream(File file, ChunkDecoder decompressor, BufferRecycler bufferRecycler) throws FileNotFoundException | |
| LZFFileInputStream | back to summary |
|---|---|
| public LZFFileInputStream(FileDescriptor fdObj, ChunkDecoder decompressor, BufferRecycler bufferRecycler) | |
| LZFFileInputStream | back to summary |
|---|---|
| public LZFFileInputStream(String name, ChunkDecoder decompressor, BufferRecycler bufferRecycler) throws FileNotFoundException | |
| available | back to summary |
|---|---|
| public int available() Overrides java. Doc from java. Returns an estimate of the number of remaining bytes that can be read (or skipped over) from this input stream without blocking by the next invocation of a method for this input stream. Returns 0 when the file position is beyond EOF. The next invocation might be the same thread or another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes. In some cases, a non-blocking read (or skip) may appear to be blocked when it is merely slow, for example when reading large files over slow networks.
| |
| close | back to summary |
|---|---|
| public void close() throws IOException Overrides java. Implements java. Doc from java. Closes this file input stream and releases any system resources associated with the stream. If this stream has an associated channel then the channel is closed as well.
| |
| read | back to summary |
|---|---|
| public int read() throws IOException Overrides java. Doc from java. Reads a byte of data from this input stream. This method blocks if no input is yet available.
| |
| read | back to summary |
|---|---|
| public int read(byte[] b) throws IOException Overrides java. Doc from java. Reads up to
| |
| read | back to summary |
|---|---|
| public int read(byte[] buffer, int offset, int length) throws IOException Overrides java. Doc from java. Reads up to
| |
| readAndWrite | back to summary |
|---|---|
| public int readAndWrite(OutputStream out) throws IOException Convenience method that will read and uncompress all data available,
and write it using given
| |
| readRaw | back to summary |
|---|---|
| protected final int readRaw(byte[] buffer, int offset, int length) throws IOException | |
| readyBuffer | back to summary |
|---|---|
| protected boolean readyBuffer() throws IOException Fill the uncompressed bytes buffer by reading the underlying inputStream. | |
| setUseFullReads | back to summary |
|---|---|
| public 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. | |
| skip | back to summary |
|---|---|
| public long skip(long n) throws IOException Overrides java. Overridden to implement efficient skipping by skipping full chunks whenever possible.
| |
| skipRaw | back to summary |
|---|---|
| protected final long skipRaw(long amount) throws IOException | |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public void | close()
Overrides java. Implements java. |
| public int | read()
Implements abstract java. |
| public int | read(byte[]
the buffer into which the data is read. buffer, int the start offset in array offset, int b
at which the data is written.the maximum number of bytes to read. length)Overrides java. len bytes of data from the input stream into
an array of bytes.
|
| public int | read(byte[]
the buffer into which the data is read. buffer)Overrides java. b.
|
| public long | skip(long
the number of bytes to be skipped. n)Overrides java. n bytes of data from this input
stream.
|
| Wrapper | back to summary |
|---|---|
| private Wrapper() | |
| close | back to summary |
|---|---|
| public void close() throws IOException Overrides java. Implements java. Doc from java. Closes this input stream and releases any system resources associated with the stream.
| |
| read | back to summary |
|---|---|
| public int read() throws IOException Implements abstract java. Doc from java. Reads the next byte of data from the input stream. The value byte is
returned as an
| |
| read | back to summary |
|---|---|
| public int read(byte[] buffer, int offset, int length) throws IOException Overrides java. Doc from java. Reads up to This method blocks until input data is available, end of file is detected, or an exception is thrown. If The first byte read is stored into element In every case, elements
| |
| read | back to summary |
|---|---|
| public int read(byte[] buffer) throws IOException Overrides java. Doc from java. Reads some number of bytes from the input stream and stores them into
the buffer array If the length of The first byte read is stored into element
| |
| skip | back to summary |
|---|---|
| public long skip(long n) throws IOException Overrides java. Doc from java. Skips over and discards
| |