public class LittleEndianBitInputStream extends InputStream implements BitInput
InputStream. The bits are read in little-endian
bit order.| Constructor and Description |
|---|
LittleEndianBitInputStream(InputStream in) |
| Modifier and Type | Method and Description |
|---|---|
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.
|
mark, markSupported, resetpublic LittleEndianBitInputStream(InputStream in) throws IOException
IOExceptionpublic boolean isAtEof()
BitInputpublic long getNumberOfBytesRead()
public void skipToByteBoundary()
throws IOException
BitInputskipToByteBoundary 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
BitInputreadBit 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
BitInputreadBits 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
BitInputreadBitsLittleEndian 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 interface AutoCloseableclose in class InputStreamIOException