Package totalcross.json.zip
Class BitInputStream
- java.lang.Object
-
- totalcross.json.zip.BitInputStream
-
-
Constructor Summary
Constructors Constructor Description BitInputStream(Stream in)Make a BitReader from an InputStream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanbit()Read one bit.longnrBits()Get the number of bits that have been read from this BitInputStream.booleanpad(int width)Check that the rest of the block has been padded with zeroes.intread(int width)Read some bits.
-
-
-
Constructor Detail
-
BitInputStream
public BitInputStream(Stream in)
Make a BitReader from an InputStream. The BitReader will take bytes from the InputStream and unpack them into bits.- Parameters:
in- An InputStream.
-
-
Method Detail
-
bit
public boolean bit() throws IOExceptionRead one bit.- Specified by:
bitin interfaceBitReader- Returns:
- true if it is a 1 bit.
- Throws:
IOException
-
nrBits
public long nrBits()
Get the number of bits that have been read from this BitInputStream. This includes pad bits that have been skipped, but might not include bytes that have been read from the underlying InputStream that have not yet been delivered as bits.
-
pad
public boolean pad(int width) throws IOExceptionCheck that the rest of the block has been padded with zeroes.- Specified by:
padin interfaceBitReader- Parameters:
width- The size of the block to pad in bits. This will typically be 8, 16, 32, 64, 128, 256, etc.- Returns:
- true if the block was zero padded, or false if the the padding contains any one bits.
- Throws:
IOException
-
read
public int read(int width) throws IOExceptionRead some bits.- Specified by:
readin interfaceBitReader- Parameters:
width- The number of bits to read. (0..32)- Returns:
- the bits
- Throws:
IOException
-
-