Class ZCompressorInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.apache.commons.compress.compressors.CompressorInputStream
-
- org.apache.commons.compress.compressors.lzw.LZWInputStream
-
- org.apache.commons.compress.compressors.z.ZCompressorInputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,InputStreamStatistics
public class ZCompressorInputStream extends LZWInputStream
Input stream that decompresses .Z files.- Since:
- 1.7
-
-
Field Summary
Fields Modifier and Type Field Description private static int
BLOCK_MODE_MASK
private boolean
blockMode
private static int
MAGIC_1
private static int
MAGIC_2
private static int
MAX_CODE_SIZE_MASK
private int
maxCodeSize
private long
totalCodesRead
-
Fields inherited from class org.apache.commons.compress.compressors.lzw.LZWInputStream
DEFAULT_CODE_SIZE, in, UNUSED_PREFIX
-
-
Constructor Summary
Constructors Constructor Description ZCompressorInputStream(java.io.InputStream inputStream)
ZCompressorInputStream(java.io.InputStream inputStream, int memoryLimitInKb)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
addEntry(int previousCode, byte character)
Add a new entry to the dictionary.private void
clearEntries()
protected int
decompressNextSymbol()
Read the next code and expand it.static boolean
matches(byte[] signature, int length)
Checks if the signature matches what is expected for a Unix compress file.protected int
readNextCode()
Reads the next code from the stream.private void
reAlignReading()
-
Methods inherited from class org.apache.commons.compress.compressors.lzw.LZWInputStream
addEntry, addRepeatOfPreviousCode, close, expandCodeToOutputStack, getClearCode, getCodeSize, getCompressedCount, getPrefix, getPrefixesLength, getTableSize, incrementCodeSize, initializeTables, initializeTables, read, read, resetCodeSize, resetPreviousCode, setClearCode, setCodeSize, setPrefix, setTableSize
-
Methods inherited from class org.apache.commons.compress.compressors.CompressorInputStream
count, count, getBytesRead, getCount, getUncompressedCount, pushedBackBytes
-
Methods inherited from class java.io.InputStream
available, mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, transferTo
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.commons.compress.utils.InputStreamStatistics
getUncompressedCount
-
-
-
-
Field Detail
-
MAGIC_1
private static final int MAGIC_1
- See Also:
- Constant Field Values
-
MAGIC_2
private static final int MAGIC_2
- See Also:
- Constant Field Values
-
BLOCK_MODE_MASK
private static final int BLOCK_MODE_MASK
- See Also:
- Constant Field Values
-
MAX_CODE_SIZE_MASK
private static final int MAX_CODE_SIZE_MASK
- See Also:
- Constant Field Values
-
blockMode
private final boolean blockMode
-
maxCodeSize
private final int maxCodeSize
-
totalCodesRead
private long totalCodesRead
-
-
Constructor Detail
-
ZCompressorInputStream
public ZCompressorInputStream(java.io.InputStream inputStream, int memoryLimitInKb) throws java.io.IOException
- Throws:
java.io.IOException
-
ZCompressorInputStream
public ZCompressorInputStream(java.io.InputStream inputStream) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
clearEntries
private void clearEntries()
-
readNextCode
protected int readNextCode() throws java.io.IOException
Reads the next code from the stream.This method is only protected for technical reasons and is not part of Commons Compress' published API. It may change or disappear without warning.
- Overrides:
readNextCode
in classLZWInputStream
- Returns:
- the next code
- Throws:
java.io.IOException
- on error
-
reAlignReading
private void reAlignReading() throws java.io.IOException
- Throws:
java.io.IOException
-
addEntry
protected int addEntry(int previousCode, byte character) throws java.io.IOException
Add a new entry to the dictionary.This method is only protected for technical reasons and is not part of Commons Compress' published API. It may change or disappear without warning.
- Specified by:
addEntry
in classLZWInputStream
- Parameters:
previousCode
- the previous codecharacter
- the next character to append- Returns:
- the new code
- Throws:
java.io.IOException
- on error
-
decompressNextSymbol
protected int decompressNextSymbol() throws java.io.IOException
Read the next code and expand it.This method is only protected for technical reasons and is not part of Commons Compress' published API. It may change or disappear without warning.
- Specified by:
decompressNextSymbol
in classLZWInputStream
- Returns:
- the expanded next code, negative on EOF
- Throws:
java.io.IOException
- on error
-
matches
public static boolean matches(byte[] signature, int length)
Checks if the signature matches what is expected for a Unix compress file.- Parameters:
signature
- the bytes to checklength
- the number of bytes to check- Returns:
- true, if this stream is a Unix compress compressed stream, false otherwise
- Since:
- 1.9
-
-