de.flashweather.io.util
Class BitInputStream
java.lang.Object
|
+--java.io.InputStream
|
+--java.io.FilterInputStream
|
+--de.flashweather.io.util.BitInputStream
- public class BitInputStream
- extends java.io.FilterInputStream
This class is an input stream wrapper that can read a specific number of
bytes and bits from an input stream.
- Author:
- Benjamin Stark
Field Summary |
protected int |
bitBuf
Buffer for one byte which will be processed bit by bit. |
protected int |
bitPos
Current bit position in bitBuf. |
Fields inherited from class java.io.FilterInputStream |
in |
Constructor Summary |
BitInputStream(java.io.InputStream in)
Constructs a bit input stream from an InputStream object. |
Method Summary |
byte[] |
read(int length)
Read specific number of bytes from the input stream. |
int |
readSBits(int numBits)
Read a signed value from the given number of bits |
long |
readUBits(int numBits)
Read an unsigned value from the given number of bits. |
int |
readUI8()
Read an unsigned 8 bit value. |
int[] |
readUI8(int length)
Read specific number of unsigned bytes from the input stream. |
Methods inherited from class java.io.FilterInputStream |
available,
close,
mark,
markSupported,
read,
read,
read,
reset,
skip |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
bitBuf
protected int bitBuf
- Buffer for one byte which will be processed bit by bit.
bitPos
protected int bitPos
- Current bit position in bitBuf.
BitInputStream
public BitInputStream(java.io.InputStream in)
- Constructs a bit input stream from an InputStream object.
- Parameters:
in
- input stream that will be wrapped
readUI8
public int readUI8()
throws java.io.IOException
- Read an unsigned 8 bit value.
- Returns:
- unsigned 8 bit value as integer
readUI8
public int[] readUI8(int length)
throws java.io.IOException
- Read specific number of unsigned bytes from the input stream.
- Parameters:
lenth
- number of bytes to read and return as integers- Returns:
- unsigned bytes as integer values
read
public byte[] read(int length)
throws java.io.IOException
- Read specific number of bytes from the input stream.
- Parameters:
length
- number of bytes to read- Returns:
- array of read bytes
readUBits
public long readUBits(int numBits)
throws java.io.IOException
- Read an unsigned value from the given number of bits.
- Parameters:
numBits
- number of bits used for the unsigned value- Returns:
- value read from numBits bits as long
readSBits
public int readSBits(int numBits)
throws java.io.IOException
- Read a signed value from the given number of bits
- Parameters:
numBits
- number of bits used for the signed value- Returns:
- value read from numBits bits as integer
© 2001 Benjamin Stark