Class ExplodingInputStream
java.lang.Object
java.io.InputStream
org.apache.commons.compress.archivers.zip.ExplodingInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
,InputStreamStatistics
The implode compression method was added to PKZIP 1.01 released in 1989.
It was then dropped from PKZIP 2.0 released in 1993 in favor of the deflate
method.
The algorithm is described in the ZIP File Format Specification.
- Since:
- 1.7
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate BitStream
The stream of bits read from the input streamprivate final CircularBuffer
Output buffer holding the decompressed dataprivate final int
The size of the sliding dictionary (4K or 8K)private BinaryTree
The binary tree containing the 64 encoded distancesprivate final InputStream
The underlying stream containing the compressed dataprivate BinaryTree
The binary tree containing the 64 encoded lengthsprivate BinaryTree
The binary tree containing the 256 encoded literals (null when only two trees are used)private final int
private final int
The number of Shannon-Fano trees (2 or 3)private long
private long
-
Constructor Summary
ConstructorsConstructorDescriptionExplodingInputStream
(int dictionarySize, int numberOfTrees, InputStream in) Create a new stream decompressing the content of the specified stream using the explode algorithm. -
Method Summary
Methods inherited from class java.io.InputStream
available, mark, markSupported, read, read, readAllBytes, readNBytes, reset, skip, transferTo
-
Field Details
-
in
The underlying stream containing the compressed data -
bits
The stream of bits read from the input stream -
dictionarySize
private final int dictionarySizeThe size of the sliding dictionary (4K or 8K) -
numberOfTrees
private final int numberOfTreesThe number of Shannon-Fano trees (2 or 3) -
minimumMatchLength
private final int minimumMatchLength -
literalTree
The binary tree containing the 256 encoded literals (null when only two trees are used) -
lengthTree
The binary tree containing the 64 encoded lengths -
distanceTree
The binary tree containing the 64 encoded distances -
buffer
Output buffer holding the decompressed data -
uncompressedCount
private long uncompressedCount -
treeSizes
private long treeSizes
-
-
Constructor Details
-
ExplodingInputStream
Create a new stream decompressing the content of the specified stream using the explode algorithm.- Parameters:
dictionarySize
- the size of the sliding dictionary (4096 or 8192)numberOfTrees
- the number of trees (2 or 3)in
- the compressed data stream
-
-
Method Details
-
init
Reads the encoded binary trees and prepares the bit stream.- Throws:
IOException
-
read
- Specified by:
read
in classInputStream
- Throws:
IOException
-
getCompressedCount
public long getCompressedCount()- Specified by:
getCompressedCount
in interfaceInputStreamStatistics
- Returns:
- the amount of raw or compressed bytes read by the stream
- Since:
- 1.17
-
getUncompressedCount
public long getUncompressedCount()- Specified by:
getUncompressedCount
in interfaceInputStreamStatistics
- Returns:
- the amount of decompressed bytes returned by the stream
- Since:
- 1.17
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
- Since:
- 1.17
-
fillBuffer
Fill the sliding dictionary with more data.- Throws:
IOException
-