public class BitInputStream extends java.lang.Object implements java.io.Closeable
| Constructor and Description |
|---|
BitInputStream(java.io.InputStream in,
java.nio.ByteOrder byteOrder)
Constructor taking an InputStream and its bit arrangement.
|
| Modifier and Type | Method and Description |
|---|---|
void |
alignWithByteBoundary()
Drops bits until the next bits will be read from a byte boundary.
|
long |
bitsAvailable()
Returns an estimate of the number of bits that can be read from
this input stream without blocking by the next invocation of a
method for this input stream.
|
int |
bitsCached()
Returns the number of bits that can be read from this input
stream without reading from the underlying input stream at all.
|
void |
clearBitCache()
Clears the cache of bits that have been read from the
underlying stream but not yet provided via
readBits(int). |
void |
close() |
long |
getBytesRead()
Returns the number of bytes read from the underlying stream.
|
long |
readBits(int count)
Returns at most 63 bits read from the underlying stream.
|
public BitInputStream(java.io.InputStream in, java.nio.ByteOrder byteOrder)
in - the InputStreambyteOrder - the bit arrangement across byte boundaries,
either BIG_ENDIAN (aaaaabbb bb000000) or LITTLE_ENDIAN (bbbaaaaa 000000bb)public void close() throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOExceptionpublic void clearBitCache()
readBits(int).public long readBits(int count) throws java.io.IOException
count - the number of bits to read, must be a positive
number not bigger than 63.java.io.IOException - on errorpublic int bitsCached()
public long bitsAvailable() throws java.io.IOException
java.io.IOException - if the underlying stream throws one when calling availablepublic void alignWithByteBoundary()
public long getBytesRead()
This includes the bytes read to fill the current cache and not read as bits so far.