|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object src.BitInputStream
public class BitInputStream
The BitInputStream allows reading individual bits from a general Java InputStream. This class is able to read a single bit from a stream It is also able to read Serializable objects.
The code is based on the following reference:
http://www.developer.nokia.com/Community/Wiki/Bit_Input/Output_Stream_utility_classes_for_efficient_data_transfer
The original author is Andreas Jakl. The code has been modified to include support for partial bytes at the end of the stream and to allow reading of serializable objects.
Constructor Summary | |
---|---|
BitInputStream(java.io.InputStream in)
Creates a BitInputStream that reads bits from the specified InputStream . |
|
BitInputStream(java.lang.String name)
Creates a BitInputStream that reads bits from the file with the given name. |
Method Summary | |
---|---|
void |
close()
Closes the underlying input stream. |
boolean |
hasNext()
Returns true if there are more bits in this stream. |
int |
readBit()
Reads the next bit from this stream. |
java.lang.Object |
readObject()
Reads the next object from this stream. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BitInputStream(java.io.InputStream in) throws java.io.IOException
BitInputStream
that reads bits from the specified InputStream
.
in
- the input stream to read from
java.io.IOException
- - if an I/O error occurs while writing stream header
java.lang.SecurityException
- - if untrusted subclass illegally overrides security-sensitive methods
java.lang.NullPointerException
- - if in
is null
public BitInputStream(java.lang.String name) throws java.io.IOException
BitInputStream
that reads bits from the file with the given name.
name
- the name of the file to read the bits from
java.io.IOException
- if an I/O error occurs
java.io.FileNotFoundException
- if the file does not exist, is a directory
rather than a regular file, or for some other reason cannot be
opened for reading.Method Detail |
---|
public boolean hasNext()
true
if there are more bits in this stream. After a call to hasNext
the method readObject
should not be called.
true
, if there are more bits in this streampublic int readBit() throws java.io.IOException
java.io.IOException
- if an I/O error occurs, or if attempting to read past the end of filepublic java.lang.Object readObject() throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
- if an I/O error occurs
java.lang.ClassNotFoundException
ObjectInputStream.readObject()
public void close() throws java.io.IOException
java.io.IOException
- if an I/O error occurs
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |