public class BitInputStream
extends java.io.FilterInputStream
Constructor and Description |
---|
BitInputStream(java.io.InputStream in) |
BitInputStream(java.io.InputStream in,
boolean littleEndian) |
Modifier and Type | Method and Description |
---|---|
int |
available()
Returns an estimate of the number of bits that can be read (or
skipped over) from this input stream without blocking by the next
caller of a method for this input stream.
|
int |
getBitCount()
The number of bits read
|
boolean |
isLittleEndian() |
void |
mark(int readlimit) |
boolean |
markSupported() |
int |
read() |
int |
read(byte[] b)
Reads up to
8*b.length bits of data from this
input stream into an array of bytes. |
int |
read(byte[] b,
int off,
int len)
Reads up to
len bits of data from this input stream
into an array of bytes. |
int |
readBits(int nbits)
Read up to 32 bits of data
|
void |
reset() |
void |
setLittleEndian(boolean littleEndian) |
long |
skip(long n) |
public BitInputStream(java.io.InputStream in)
public BitInputStream(java.io.InputStream in, boolean littleEndian)
public void setLittleEndian(boolean littleEndian)
public boolean isLittleEndian()
public int getBitCount()
public int readBits(int nbits) throws java.io.IOException
nbits
- number of bits to readjava.io.IOException
public int read() throws java.io.IOException
read
in class java.io.FilterInputStream
java.io.IOException
public int read(byte[] b) throws java.io.IOException
8*b.length
bits of data from this
input stream into an array of bytes. This method blocks until some
input is available.read
in class java.io.FilterInputStream
b
- the buffer into which the data is read.-1
if there is no more data because the end of
the stream has been reached.java.io.IOException
- if an I/O error occurs.read(byte[], int, int)
public int read(byte[] b, int off, int len) throws java.io.IOException
len
bits of data from this input stream
into an array of bytes. If len
is not zero, the method
blocks until some input is available; otherwise, no
bytes are read and 0
is returned.read
in class java.io.FilterInputStream
b
- the buffer into which the data is read.off
- the start bit offset in the destination array b
len
- the maximum number of bits read.-1
if there is no more data because the end of
the stream has been reached.java.lang.NullPointerException
- If b
is null
.java.lang.IndexOutOfBoundsException
- If off
is negative,
len
is negative, or len
is greater than
8*b.length - off
java.io.IOException
- if an I/O error occurs.public long skip(long n) throws java.io.IOException
skip
in class java.io.FilterInputStream
java.io.IOException
public int available() throws java.io.IOException
This method returns the result of in
.available().
available
in class java.io.FilterInputStream
java.io.IOException
- if an I/O error occurs.public void mark(int readlimit)
mark
in class java.io.FilterInputStream
public void reset() throws java.io.IOException
reset
in class java.io.FilterInputStream
java.io.IOException
public boolean markSupported()
markSupported
in class java.io.FilterInputStream