Package com.webcodepro.shrinkit.io
Class LzwInputStream
- java.lang.Object
-
- java.io.InputStream
-
- com.webcodepro.shrinkit.io.LzwInputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class LzwInputStream extends java.io.InputStream
This is the generic Shrinkit LZW decompression algorithm. It does not deal with the vagaries of the LZW/1 and LZW/2 data streams. It does, however, deal with dictionary clears (0x100) and theBitInputStream
bit sizes.
-
-
Constructor Summary
Constructors Constructor Description LzwInputStream(BitInputStream is)
Create theLzwInputStream
based on the givenBitInputStream
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearData()
Provide necessary housekeeping to reset LZW stream between NuFX buffer changes.void
clearDictionary()
Clear out the dictionary.void
fillBuffer()
Fill the buffer up with some decompressed data.int
read()
Answer with the next byte from the (now) decompressed input stream.
-
-
-
Constructor Detail
-
LzwInputStream
public LzwInputStream(BitInputStream is)
Create theLzwInputStream
based on the givenBitInputStream
.- See Also:
BitInputStream
-
-
Method Detail
-
read
public int read() throws java.io.IOException
Answer with the next byte from the (now) decompressed input stream.- Specified by:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
fillBuffer
public void fillBuffer() throws java.io.IOException
Fill the buffer up with some decompressed data. This may range from one byte to many bytes, depending on what is in the dictionary.- Throws:
java.io.IOException
- See Also:
- Wikipedia for the general algorithm
-
clearDictionary
public void clearDictionary()
Clear out the dictionary. It will be rebuilt on the next call tofillBuffer
.
-
clearData
public void clearData()
Provide necessary housekeeping to reset LZW stream between NuFX buffer changes. The dictionary is the only item that is not cleared -- that needs to be done explicitly since behavior between LZW/1 and LZW/2 differ.
-
-