|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface BitInput
This interface identifies a source for bits.
The source is assumed to have a position which may or may not be at a byte boundary (every eight bits).
If an implementing class also extends InputStream
it can be
used as an input stream. This interface redefines InputStream
's read methods with the extra condition that they may only be used if the
current position of the source is at a byte boundary. The
readBytes(byte[], int, int)
method does not have that limitation.
InputStream
,
BitOutput
Method Summary | |
---|---|
int |
available()
Get the number of bytes available in the input. |
boolean |
isAtEof()
Has the input come to its end? If so, nothing more can be read from it. |
int |
read()
Read a single byte from the input. |
int |
read(byte[] barr)
Read bytes into the supplied array. |
int |
read(byte[] barr,
int offset,
int len)
Read bytes into the supplied array. |
boolean |
readBit()
Read the value of the next bit in the stream. |
int |
readBits(int no)
Read up to eight bits from the input. |
int |
readBitsLittleEndian(int no)
Read up to 32 bits from the input. |
byte[] |
readBytes(byte[] barr,
int off,
int len)
Read bytes from the input. |
long |
skip(long n)
Skip bytes in the input. |
void |
skipToByteBoundary()
Move the position to the next byte boundary. |
Methods inherited from interface java.io.Closeable |
---|
close |
Method Detail |
---|
boolean isAtEof()
true
if no more can be read from this input.void skipToByteBoundary() throws IOException
IOException
- On I/O errors or if this input is already at the end
of the available data.boolean readBit() throws IOException
true
if the value is 1, false
if it is 0.
IOException
- On I/O errors or if this input is already at the end
of the available data.int readBits(int no) throws IndexOutOfBoundsException, IOException
no
- The number of bits to read.
1011
is read, the returned integer will have the
value 1 * 8 + 0 * 4 + 1 * 2 + 1 * 1 == 11
.
IndexOutOfBoundsException
- If no
is less than 0 or greater
than 8.
IOException
- On I/O errors or if this input is already at the end
of the available data.readBitsLittleEndian(int)
int readBitsLittleEndian(int no) throws IndexOutOfBoundsException, IOException
no
- The number of bits to read.
readBits(int)
.
IndexOutOfBoundsException
- If no
is less than 0 or greater
than 32.
IOException
- On I/O errors or if this input is already at the end
of the available data.readBits(int)
byte[] readBytes(byte[] barr, int off, int len) throws IndexOutOfBoundsException, IOException
read(byte[], int, int)
, this
method does not require that the current position is at a byte boundary.
Another difference to read(byte[], int, int)
is that this method
throws an IOException
if it cannot read all requested bytes.
barr
- The byte array to read bytes into.off
- The offset in the array to start writing read bytes at.len
- The number of bytes to read.
barr
.
IndexOutOfBoundsException
- If the length or the offset is negative
or if the sum of the length and the offset is greater than the length of
the supplied byte array.
IOException
- On I/O errors or if there was not enough bytes to
read from the input.read(byte[], int, int)
int read() throws IOException
InputStream.read()
.
This method requires that the current position in the input is at a byte boundary.
-1
if the current position is at the end
of the input.
IOException
- On I/O errors or if the current position is not at a
byte boundary.InputStream.read()
int read(byte[] barr) throws IOException
InputStream.read(byte[])
.
This method requires that the current position in the input is at a byte boundary.
barr
- The byte array to read bytes into.
IOException
- On I/O errors or if the current position is not at a
byte boundary.InputStream.read(byte[])
int read(byte[] barr, int offset, int len) throws IndexOutOfBoundsException, IOException
InputStream.read(byte[], int, int)
.
This method requires that the current position in the input is at a byte boundary.
barr
- The byte array to read bytes into.offset
- The offset position in the array to start write read bytes
to.len
- The number of bytes to read.
IndexOutOfBoundsException
- If the offset or the length is negative
or if the sum of the offset and the length is greater than the length of
the supplied byte array.
IOException
- On I/O errors or if the current position is not at a
byte boundary.long skip(long n) throws IOException
InputStream.skip(long)
.
This method requires that the current position in the input is at a byte boundary.
n
- The number of bytes to skip.
IOException
- On I/O errors or if the current position is not at a
byte boundary.int available() throws IOException
InputStream.available()
.
This method requires that the current position in the input is at a byte boundary.
IOException
- On I/O errors or if the current position is not at a
byte boundary.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |