|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.InputStream
BitInputStream
This class is a buffered input stream that allows for users to easily read bits and bytes from the underlying stream. All methods use computer arithmetic to maipulate the bits, and have a default buffer of 64 bits (long).
Usage: Identical to the BufferedInputStream. ie. BitInputStream out = new BitInputStream(new FileInputStream(file));
Field Summary | |
protected long |
buf
The 'long' buffer that stores the bits. |
protected int |
bufLength
A 'long' is represented by 64 bits, thus the length of the buffer is 64 bits. |
protected long[] |
byteLReduce
The reduce arrays used to reduce large values. |
protected int |
count
The current location in the buffer. |
protected int |
curBufLength
A 'long' is represented by 64 bits, thus the length of the buffer is 64 bits. |
protected long[] |
longLReduce
The reduce arrays used to reduce large values. |
protected long[] |
outReduce
The reduce arrays used to reduce large values. |
Constructor Summary | |
BitInputStream(java.io.InputStream is)
|
Method Summary | |
int |
available()
Returns the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream. |
long |
availableBits()
Returns 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. |
void |
close()
Closes this input stream and releases any system resources associated with the stream. |
boolean |
markSupported()
Tests if this input stream supports the mark and reset methods. |
int |
read()
Reads the next byte of data from the input stream. |
int |
read(byte[] b)
Reads some number of bytes from the input stream and stores them into the buffer array b. |
int |
read(byte[] b,
int off,
int len)
Reads up to len bytes of data from the input stream into an array of bytes. |
boolean |
readBit()
Reads a single bit from the input stream, which is returned. |
int |
readBits(boolean[] b,
int off,
int len)
Reads a series of bits from the input stream, which will then be written to the boolean array with the specified offset and for the specified length. |
int |
readByte()
Reads the next UNSIGNED byte of data from the input stream. |
int |
readBytes(byte[] b,
int off,
int len)
Reads up to len bytes of data from the input stream into an array of bytes. |
int |
readInt()
Reads an int value from the input stream, which is 4 bytes. |
long |
readLong()
Reads a long value from the input stream, which is 8 bytes. |
java.lang.String |
readString(int len)
Reads a String from the input stream given the expected length of the String to read. |
long |
skip(long n)
Skips over and discards n bytes of data from this input stream INCLUDING any half bits that are currently being read in the buffer. |
long |
skipBits(long n)
|
java.lang.String |
toString()
Returns a String representation of the state of the current buffer in binary form, as well as any variables associated with the buffer. |
Methods inherited from class java.io.InputStream |
mark, reset |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected long buf
protected int bufLength
protected int curBufLength
protected int count
protected long[] byteLReduce
protected long[] longLReduce
protected long[] outReduce
Constructor Detail |
public BitInputStream(java.io.InputStream is) throws java.io.IOException
Method Detail |
public boolean markSupported()
public int available() throws java.io.IOException
java.io.IOException
public long availableBits() throws java.io.IOException
java.io.IOException
public void close() throws java.io.IOException
java.io.IOException
public long skip(long n) throws java.io.IOException
java.io.IOException
public long skipBits(long n) throws java.io.IOException
java.io.IOException
public int read() throws java.io.IOException
java.io.IOException
public int read(byte[] b) throws java.io.IOException
java.io.IOException
public int read(byte[] b, int off, int len) throws java.io.IOException
java.io.IOException
public int readByte() throws java.io.IOException
java.io.IOException
public int readBytes(byte[] b, int off, int len) throws java.io.IOException
java.io.IOException
public boolean readBit() throws java.io.IOException
java.io.IOException
public int readBits(boolean[] b, int off, int len) throws java.io.IOException
java.io.IOException
public int readInt() throws java.io.IOException
java.io.IOException
public long readLong() throws java.io.IOException
java.io.IOException
public java.lang.String readString(int len) throws java.io.IOException
len
- the length (in bytes) of the String to be read, including the current (possibly half) byte.
java.io.IOException
public java.lang.String toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |