public final class LzmaInputStream extends InputStream
InputStream
for decoding data using
the Lempel-Ziv-Markov chain algorithm. It uses the LZMA decoder from the LZMA SDK.
The API from the LZMA SDK is built around a standalone decoder. To adapt that into the Java streams API, the decoder is launched in a separate execution thread. The decoder writes data to a blocking queue that this stream reads its data from.
Errors are propagated up from the decoder to the calling thread. If an error occurs in the decoder, it will be reported to the calling thread the next time that it tries to read from or close the stream.
Decoding a file consumes a lot of memory – up to the dictionary size set when encoding it multiplied with the decoder data queue depth plus one. (The default dictionary size is 2^23 = 8.4 MB and the default data queue depth is 1.)
By default, data in an LZMA stream has the following format:
LzmaInputStreamSettings
object that says which headers the stream can
expect to find.LzmaInputStreamSettings
,
LzmaOutputStream
Constructor and Description |
---|
LzmaInputStream(InputStream is)
Create a LZMA decoding stream using the default settings.
|
LzmaInputStream(InputStream is,
LzmaInputStreamSettings settings)
Create a LZMA decoding stream using custom settings.
|
public LzmaInputStream(InputStream is)
is
- The stream containing LZMA encoded data. Since this stream is
read in a separate thread, a lock-aware stream such as one returned from
Files.openForRead(org.entityfs.ReadableFile)
cannot be used.LzmaInputStream(InputStream, LzmaInputStreamSettings)
,
LzmaInputStreamSettings
public LzmaInputStream(InputStream is, LzmaInputStreamSettings settings) throws IllegalArgumentException
is
- The stream containing LZMA encoded data. Since this stream is
read in a separate thread, a lock-aware stream such as one returned from
Files.openForRead(org.entityfs.ReadableFile)
cannot be used.settings
- The compression settings that were used when writing the
compressed data.IllegalArgumentException
- If the uncompressed size is less than
-1.public int read() throws IOException
read
in class InputStream
IOException
public int read(byte[] barr) throws IOException
read
in class InputStream
IOException
public int read(byte[] barr, int off, int len) throws IOException
read
in class InputStream
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class InputStream
IOException