Maven module :un.storage : archive-xz :
Class : un.storage.archive.xz.SingleXZInputStream
Extends/Implements : java.io.InputStream
Subclasses : -

Decompresses exactly one XZ Stream in streamed mode (no seeking).
The decompression stops after the first XZ Stream has been decompressed,
and the read position in the input stream is left at the first byte
after the end of the XZ Stream. This can be useful when XZ data has
been stored inside some other file format or protocol.


Unless you know what you are doing, don't use this class to decompress
standalone .xz files. For that purpose, use XZInputStream.

When uncompressed size is known beforehand



If you are decompressing complete XZ streams and your application knows
exactly how much uncompressed data there should be, it is good to try
reading one more byte by calling read() and checking
that it returns -1. This way the decompressor will parse the
file footers and verify the integrity checks, giving the caller more
confidence that the uncompressed data is valid.

@see XZInputStream



Variables : -
Functions : SingleXZInputStream, SingleXZInputStream, SingleXZInputStream, getCheckType, getCheckName, read, read, available, close




Creates a new XZ decompressor that decompresses exactly one
XZ Stream from in without a memory usage limit.


This constructor reads and parses the XZ Stream Header (12 bytes)
from in. The header of the first Block is not read
until read is called.

@param in input stream from which XZ-compressed
data is read

@throws XZFormatException
input is not in the XZ format

@throws CorruptedInputException
XZ header CRC32 doesn't match

@throws UnsupportedOptionsException
XZ header is valid but specifies options
not supported by this implementation

@throws EOFException
less than 12 bytes of input was available
from in

@throws IOException may be thrown by in

public void SingleXZInputStream (InputStream in)


Creates a new XZ decompressor that decompresses exactly one
XZ Stream from in with an optional memory usage limit.


This is identical to SingleXZInputStream(InputStream)
except that this takes also the memoryLimit argument.

@param in input stream from which XZ-compressed
data is read

@param memoryLimit memory usage limit in kibibytes (KiB)
or -1 to impose no
memory usage limit

@throws XZFormatException
input is not in the XZ format

@throws CorruptedInputException
XZ header CRC32 doesn't match

@throws UnsupportedOptionsException
XZ header is valid but specifies options
not supported by this implementation

@throws EOFException
less than 12 bytes of input was available
from in

@throws IOException may be thrown by in

public void SingleXZInputStream (InputStream in, int memoryLimit)

void SingleXZInputStream (InputStream in, int memoryLimit, byte[] streamHeader)


Gets the ID of the integrity check used in this XZ Stream.
return   the Check ID specified in the XZ Stream Header
public int getCheckType ()


Gets the name of the integrity check used in this XZ Stream.
return   the name of the check specified in the XZ Stream Header
public String getCheckName ()


Decompresses the next byte from this input stream.


Reading lots of data with read() from this input stream
may be inefficient. Wrap it in {@link java.io.BufferedInputStream}
if you need to read lots of data one byte at a time.

@return the next decompressed byte, or -1
to indicate the end of the compressed stream

@throws CorruptedInputException
@throws UnsupportedOptionsException
@throws MemoryLimitException

@throws XZIOException if the stream has been closed

@throws EOFException
compressed input is truncated or corrupt

@throws IOException may be thrown by in

public int read ()


Decompresses into an array of bytes.


If len is zero, no bytes are read and 0
is returned. Otherwise this will try to decompress len
bytes of uncompressed data. Less than len bytes may
be read only in the following situations:



@param buf target buffer for uncompressed data
@param off start offset in buf
@param len maximum number of uncompressed bytes to read

@return number of bytes read, or -1 to indicate
the end of the compressed stream

@throws CorruptedInputException
@throws UnsupportedOptionsException
@throws MemoryLimitException

@throws XZIOException if the stream has been closed

@throws EOFException
compressed input is truncated or corrupt

@throws IOException may be thrown by in
public int read (byte[] buf, int off, int len)


Returns the number of uncompressed bytes that can be read
without blocking. The value is returned with an assumption
that the compressed input data will be valid. If the compressed
data is corrupt, CorruptedInputException may get
thrown before the number of bytes claimed to be available have
been read from this input stream.
return   the number of uncompressed bytes that can be read
without blocking
public int available ()


Closes the stream and calls in.close().
If the stream was already closed, this does nothing.
throws   IOException if thrown by in.close()
public void close ()