|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.InputStream
org.at4j.support.io.LittleEndianBitInputStream
public class LittleEndianBitInputStream
This is an input stream that a client can use to read single or several bits
from an underlying InputStream. The bits are read in little-endian
bit order.
| Constructor Summary | |
|---|---|
LittleEndianBitInputStream(InputStream in)
|
|
| Method Summary | |
|---|---|
int |
available()
Get the number of bytes available in the input. |
void |
close()
|
long |
getNumberOfBytesRead()
Get the number of whole bytes read this far. |
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 class java.io.InputStream |
|---|
mark, markSupported, reset |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public LittleEndianBitInputStream(InputStream in)
throws IOException
IOException| Method Detail |
|---|
public boolean isAtEof()
BitInput
isAtEof in interface BitInputtrue if no more can be read from this input.public long getNumberOfBytesRead()
public void skipToByteBoundary()
throws IOException
BitInput
skipToByteBoundary in interface BitInputIOException - On I/O errors or if this input is already at the end
of the available data.
public boolean readBit()
throws IOException
BitInput
readBit in interface BitInputtrue 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.
public int readBits(int no)
throws IOException,
IndexOutOfBoundsException
BitInput
readBits in interface BitInputno - 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.
IOException - On I/O errors or if this input is already at the end
of the available data.
IndexOutOfBoundsException - If no is less than 0 or greater
than 8.BitInput.readBitsLittleEndian(int)
public int readBitsLittleEndian(int no)
throws IOException,
IndexOutOfBoundsException
BitInput
readBitsLittleEndian in interface BitInputno - The number of bits to read.
BitInput.readBits(int).
IOException - On I/O errors or if this input is already at the end
of the available data.
IndexOutOfBoundsException - If no is less than 0 or greater
than 32.BitInput.readBits(int)
public byte[] readBytes(byte[] barr,
int off,
int len)
throws IOException,
IndexOutOfBoundsException
BitInputBitInput.read(byte[], int, int), this
method does not require that the current position is at a byte boundary.
Another difference to BitInput.read(byte[], int, int) is that this method
throws an IOException if it cannot read all requested bytes.
readBytes in interface BitInputbarr - 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.
IOException - On I/O errors or if there was not enough bytes to
read from the input.
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.BitInput.read(byte[], int, int)
public int read()
throws IOException
BitInputInputStream.read()
.
This method requires that the current position in the input is at a byte boundary.
read in interface BitInputread in class InputStream-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()
public int read(byte[] barr)
throws IOException
BitInputInputStream.read(byte[]).
This method requires that the current position in the input is at a byte boundary.
read in interface BitInputread in class InputStreambarr - 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[])
public int read(byte[] barr,
int offset,
int len)
throws IndexOutOfBoundsException,
IOException
BitInputInputStream.read(byte[], int, int).
This method requires that the current position in the input is at a byte boundary.
read in interface BitInputread in class InputStreambarr - 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.
public long skip(long n)
throws IOException
BitInputInputStream.skip(long).
This method requires that the current position in the input is at a byte boundary.
skip in interface BitInputskip in class InputStreamn - The number of bytes to skip.
IOException - On I/O errors or if the current position is not at a
byte boundary.
public int available()
throws IOException
BitInputInputStream.available().
This method requires that the current position in the input is at a byte boundary.
available in interface BitInputavailable in class InputStreamIOException - On I/O errors or if the current position is not at a
byte boundary.
public void close()
throws IOException
close in interface Closeableclose in class InputStreamIOException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||