public class ByteQueue
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private int |
available
How many bytes in the buffer are valid data.
|
private byte[] |
databuf
The buffer where we store our data.
|
private static int |
INITBUFSIZE
The initial size for our buffer.
|
private int |
skipped
How many bytes at the beginning of the buffer are skipped.
|
Constructor and Description |
---|
ByteQueue() |
Modifier and Type | Method and Description |
---|---|
void |
addData(byte[] data,
int offset,
int len)
Add some data to our buffer.
|
static int |
nextTwoPow(int i) |
void |
read(byte[] buf,
int offset,
int len,
int skip)
Read data from the buffer.
|
void |
removeData(int i)
Remove some bytes from our data from the beginning.
|
int |
size() |
private static final int INITBUFSIZE
private byte[] databuf
private int skipped
private int available
public static final int nextTwoPow(int i)
public void read(byte[] buf, int offset, int len, int skip)
buf
- The buffer where the read data will be copied to.offset
- How many bytes to skip at the beginning of buf.len
- How many bytes to read at all.skip
- How many bytes from our data to skip.public void addData(byte[] data, int offset, int len)
data
- A byte-array to read data from.offset
- How many bytes to skip at the beginning of the array.len
- How many bytes to read from the array.public void removeData(int i)
i
- How many bytes to remove.public int size()