public class BitwiseOutputStream extends Object
Modifier and Type | Class and Description |
---|---|
static class |
BitwiseOutputStream.AccessException
An exception to report access problems.
|
Constructor and Description |
---|
BitwiseOutputStream(int startingLength)
Create object from hint at desired size.
|
Modifier and Type | Method and Description |
---|---|
void |
skip(int bits)
Increment the current position, implicitly writing zeros.
|
byte[] |
toByteArray()
Return byte array containing accumulated data, sized to just fit.
|
void |
write(int bits,
int data)
Write some data and increment the current position.
|
void |
writeByteArray(int bits,
byte[] arr)
Write data in bulk from a byte array and increment the current position.
|
public BitwiseOutputStream(int startingLength)
startingLength
- initial internal byte array length in bytespublic byte[] toByteArray()
public void write(int bits, int data) throws BitwiseOutputStream.AccessException
bits
- the amount of data to write (gte 0, lte 8)data
- to write, will be masked to expose only bits param from lsbBitwiseOutputStream.AccessException
public void writeByteArray(int bits, byte[] arr) throws BitwiseOutputStream.AccessException
bits
- the amount of data to writearr
- the byte array containing data to be writtenBitwiseOutputStream.AccessException
public void skip(int bits)
bits
- the amount by which to increment the position