|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.InputStream BitInputStream
public class BitInputStream
The BitOutputStream and BitInputStream classes provide the ability to write and read individual bits to a file in a compact form. One minor limitation of this approach is that the resulting file will always have a number of bits that is a multiple of 8. In effect, whatever bits are output to the file are padded at the end with 0s to make the total number of bits a multiple of 8.
Constructor Summary | |
---|---|
BitInputStream(java.io.InputStream input)
Creates a BitInputStream reading bits of input from the given stream source. |
|
BitInputStream(java.io.InputStream input,
BitOutputStream partner,
boolean bitMode)
Creates a BitInputStream reading bits/bytes input from the given stream source and partnered with the given bit output stream. |
|
BitInputStream(java.io.InputStream input,
boolean bitMode)
Creates a BitInputStream reading bits/bytes input from the given stream source. |
Method Summary | |
---|---|
int |
available()
Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next invocation of a method for this input stream. |
void |
close()
Closes this stream for reading. |
protected void |
finalize()
Called by Java when the program is shutting down; included to help ensure that the stream is closed. |
boolean |
hasNextBit()
Returns whether this stream has more bits available to be read. |
boolean |
inBitMode()
Returns whether this stream is in real 'bit mode', reading a bit from the file for each call to readBit. |
int |
read()
Reads and returns a single byte of information from this stream. |
int |
read(byte[] bytes)
Reads and returns some bytes of information from this stream into the given array. |
int |
read(byte[] bytes,
int offset,
int length)
Reads and returns some bytes of information from this stream into the given array. |
int |
readBit()
Reads and returns the next single bit of input from this stream. |
java.lang.String |
readLine()
Reads and returns an entire line of text from this bit input stream as a String. |
void |
setBitMode(boolean bitMode)
Sets whether this stream is in real 'bit mode', reading a bit from the file for each call to readBit (as described under inBitMode). |
Methods inherited from class java.io.InputStream |
---|
mark, markSupported, reset, skip |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BitInputStream(java.io.InputStream input)
input
- the input stream to read.
BitIOException
- if the input stream cannot be accessed.public BitInputStream(java.io.InputStream input, boolean bitMode)
input
- the input stream to read.bitMode
- true to write bits at a time; false to write ASCII
characters (bytes) at a time for debugging.
BitIOException
- if the input stream cannot be accessed.public BitInputStream(java.io.InputStream input, BitOutputStream partner, boolean bitMode)
input
- the input stream to read.partner
- a "partner" bit output stream to watch for EOF.bitMode
- true to write bits at a time; false to write ASCII
characters (bytes) at a time for debugging.
BitIOException
- if the input stream cannot be accessed.
java.lang.NullPointerException
- if the given input or output stream is null.
(The partner can be null; simply won't partner with any bit output stream
in such a case.)Method Detail |
---|
public int available()
available
in class java.io.InputStream
BitIOException
- if the input stream cannot be accessed.public void close()
close
in interface java.io.Closeable
close
in class java.io.InputStream
BitIOException
- if the input stream cannot be closed.public boolean hasNextBit()
public boolean inBitMode()
public int read()
read
in class java.io.InputStream
BitIOException
- if the input stream cannot be read.public int read(byte[] bytes)
read
in class java.io.InputStream
bytes
- array of byte to fill
BitIOException
- if the input stream cannot be read.
java.lang.NullPointerException
- if bytes is null.public int read(byte[] bytes, int offset, int length)
read
in class java.io.InputStream
bytes
- array of byte to fill
BitIOException
- if the input stream cannot be read.
java.lang.NullPointerException
- if bytes is null.
java.lang.ArrayIndexOutOfBoundsException
- if offset + length is past the end
of the array.public int readBit()
BitIOException
- if the input stream cannot be read.public java.lang.String readLine()
BitIOException
- if the input stream cannot be read.public void setBitMode(boolean bitMode)
bitMode
- true to use bit mode, false to use byte mode.protected void finalize()
finalize
in class java.lang.Object
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |