public class BitBuffer extends Object
| Constructor and Description |
|---|
BitBuffer(byte[] b)
Creates a new bit buffer that wraps array b starting at offset 0
|
BitBuffer(byte[] b,
int offset)
Creates a new bit buffer that wraps the array b starting at offset (in bytes)
|
| Modifier and Type | Method and Description |
|---|---|
byte[] |
array() |
int |
arrayLength()
returns the backing array length in bytes!
|
long |
getBits(int numBits)
reads numBits from the buffer and returns them into a long on the rightmost position.
|
byte |
getByte()
fast getByte - only works when position%8 = 0 - otherwise throws an IllegalStateException
advances the position by 8 bits
|
void |
getByteArray(byte[] dst)
Copies bytes from the buffer to the given destination array.
|
ByteOrder |
getByteOrder() |
int |
getPosition()
get position in bits
|
int |
offset()
Returns the offset inside the byte array where this buffer starts
|
int |
remainingBytes()
Returns the remaining bytes from position until the end of the buffer.
|
void |
setByteOrder(ByteOrder order) |
void |
setPosition(int position)
set position in bits
|
int |
sizeInBits()
returns the size of the buffer (from the offset to the end of the byte array) in bits
|
BitBuffer |
slice()
Creates a new BitBuffer backed by the same array but with the offset set at the current position of this buffer
Works only when position%8 = 0 - otherwise throws an IllegalStateException
|
public BitBuffer(byte[] b)
b - public BitBuffer(byte[] b,
int offset)
b - offset - public long getBits(int numBits)
numBits - public int getPosition()
public void setPosition(int position)
position - public void setByteOrder(ByteOrder order)
public ByteOrder getByteOrder()
public byte getByte()
public void getByteArray(byte[] dst)
dst - - destination arraypublic int sizeInBits()
public int arrayLength()
public BitBuffer slice()
public byte[] array()
public int offset()
public int remainingBytes()
Copyright © 2018 Space Applications Services. All rights reserved.