Package com.helger.commons.io.stream
Class BitInputStream
- java.lang.Object
-
- com.helger.commons.io.stream.NonBlockingBitInputStream
-
- com.helger.commons.io.stream.BitInputStream
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class BitInputStream extends NonBlockingBitInputStream
TheBitInputStreamallows reading individual bits from a general Java InputStream. Like the various Stream-classes from Java, the BitInputStream has to be created based on another Input stream. It provides a function to read the next bit from the stream, as well as to read multiple bits at once and write the resulting data into an integer value.
For a non-blocking version seeNonBlockingBitInputStream.- Author:
- Andreas Jakl, Philip Helger
-
-
Constructor Summary
Constructors Constructor Description BitInputStream(InputStream aIS, ByteOrder aByteOrder)Create a new bit input stream based on an existing Java InputStream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close the underlying input stream.intreadBit()Read the next bit from the stream.-
Methods inherited from class com.helger.commons.io.stream.NonBlockingBitInputStream
getByteOrder, readBits, toString
-
-
-
-
Constructor Detail
-
BitInputStream
public BitInputStream(@Nonnull InputStream aIS, @Nonnull ByteOrder aByteOrder)
Create a new bit input stream based on an existing Java InputStream.- Parameters:
aIS- the input stream this class should read the bits from. May not benull.aByteOrder- The non-nullbyte order to use.
-
-
Method Detail
-
readBit
public int readBit() throws IOExceptionRead the next bit from the stream.- Overrides:
readBitin classNonBlockingBitInputStream- Returns:
- 0 if the bit is 0, 1 if the bit is 1.
- Throws:
IOException- In case EOF is reached
-
close
public void close()
Close the underlying input stream.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classNonBlockingBitInputStream
-
-