|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object BitReader
public class BitReader
A class that wraps any InputStream to support bitwise reads.
Constructor Summary | |
---|---|
BitReader(InputStream s)
Creates a new BitInStream instance that wraps the given InputStream. |
Method Summary | |
---|---|
void |
close()
Closes the underlying InputStream. |
static void |
main(String[] args)
Unit test on file test.txt presumed to have contents "Hello." |
boolean |
readBit()
Reads the next bit, returning true if 1, false if 0. |
int |
readBits(int n)
Reads the next n bits, and returns them as the least significant n bits of an int, with earliest read bit at high-end. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BitReader(InputStream s)
s
- an underlying InputStreamMethod Detail |
---|
public void close() throws IOException
IOException
- if underlying InputStream throws such an exceptionpublic boolean readBit() throws IOException
IOException
- if underlying InputStream throws such an exceptionpublic int readBits(int n) throws IOException
n
- Number of bits (must be 0 <= n <= 32)
IOException
- if underlying InputStrea throws such an exceptionpublic static void main(String[] args) throws IOException
args
-
IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |