org.freehep.util.io
Class BitInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.freehep.util.io.DecompressableInputStream
-
- org.freehep.util.io.BitInputStream
-
- All Implemented Interfaces:
- java.io.Closeable, java.lang.AutoCloseable
- Direct Known Subclasses:
- ByteOrderInputStream
public class BitInputStream extends DecompressableInputStream
Class to read bits from a Stream, allowing for byte synchronization. Signed, Unsigned, Booleans and Floats can be read.
-
-
Constructor Summary
Constructors Constructor and Description BitInputStream(java.io.InputStream in)Create a Bit input stream from viven input
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidbyteAlign()A utility to force the next read to be byte-aligned.booleanreadBitFlag()Read a bit from the input stream and interpret this as a boolean value.floatreadFBits(int n)Read a float value of n-bits from the stream.longreadSBits(int n)Read a signed value of n-bits from the input stream.longreadUBits(int n)Read an unsigned value of n-bits from the input stream.-
Methods inherited from class org.freehep.util.io.DecompressableInputStream
read, skip, startDecompressing
-
-
-
-
Constructor Detail
-
BitInputStream
public BitInputStream(java.io.InputStream in)
Create a Bit input stream from viven input- Parameters:
in- stream to read from
-
-
Method Detail
-
byteAlign
public void byteAlign()
A utility to force the next read to be byte-aligned.
-
readBitFlag
public boolean readBitFlag() throws java.io.IOExceptionRead a bit from the input stream and interpret this as a boolean value. A 1-bit is true; a 0-bit is false.- Returns:
- true if read bit was 1
- Throws:
java.io.IOException- if read fails
-
readSBits
public long readSBits(int n) throws java.io.IOExceptionRead a signed value of n-bits from the input stream.- Parameters:
n- number of bits to read- Returns:
- value made up of read bits
- Throws:
java.io.IOException- if read fails
-
readFBits
public float readFBits(int n) throws java.io.IOExceptionRead a float value of n-bits from the stream.- Parameters:
n- number of bits to read- Returns:
- value made up of read bits
- Throws:
java.io.IOException- if read fails
-
readUBits
public long readUBits(int n) throws java.io.IOExceptionRead an unsigned value of n-bits from the input stream.- Parameters:
n- number of bits to read- Returns:
- value made up of read bits
- Throws:
java.io.IOException- if read fails
-
-
DMelt 3.0 © DataMelt by jWork.ORG