|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectjava.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 0's 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,
boolean bitMode)
Creates a BitInputStream reading bits/bytes input from the given stream source. |
|
| Method Summary | |
|---|---|
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 |
readBit()
Reads and returns the next single bit of input from this stream. |
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 |
|---|
available, mark, markSupported, read, read, 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)
throws java.io.IOException
input - the input stream to read.
java.io.IOException - if the input stream cannot be accessed.
public BitInputStream(java.io.InputStream input,
boolean bitMode)
throws java.io.IOException
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.
java.io.IOException - if the input stream cannot be accessed.| Method Detail |
|---|
public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in class java.io.InputStreamjava.io.IOException - if the input stream cannot be closed.public boolean hasNextBit()
public boolean inBitMode()
public int read()
throws java.io.IOException
read in class java.io.InputStreamjava.io.IOException - if the input stream cannot be read.
public int readBit()
throws java.io.IOException
java.io.IOException - 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 | |||||||