public class ByteBuffer extends Object implements Serializable
| Modifier and Type | Field and Description |
|---|---|
protected byte[] |
data
The buffer where data is stored.
|
protected int |
length
The number of valid bytes in this buffer.
|
| Constructor and Description |
|---|
ByteBuffer()
Constructs a new
ByteBuffer with default initial capacity. |
ByteBuffer(byte[] array)
Constructs a new
ByteBuffer with the specified initial data. |
ByteBuffer(byte[] array,
int offset,
int count)
Constructs a new
ByteBuffer with the specified initial data. |
ByteBuffer(int capacity)
Constructs a new
ByteBuffer with the specified initial
capacity. |
| Modifier and Type | Method and Description |
|---|---|
ByteBuffer |
append(boolean value)
Appends the specified
boolean value to this buffer as a
1-byte value. |
ByteBuffer |
append(boolean[] array)
Appends the specified
boolean[] array to this buffer. |
ByteBuffer |
append(boolean[] array,
int offset,
int count)
Appends the specified number of elements from the specified
boolean[] array starting from the specified offset to this
buffer. |
ByteBuffer |
append(byte value)
Appends the specified
byte value to this buffer. |
ByteBuffer |
append(byte[] array)
Appends the specified
byte[] array to this buffer. |
ByteBuffer |
append(byte[] array,
int offset,
int count)
Appends the specified number of elements from the specified
byte[] array starting from the specified offset to this
buffer. |
ByteBuffer |
append(ByteBuffer buffer)
Appends all the data from the specified buffer to this buffer.
|
ByteBuffer |
append(char value)
Appends the specified
char value to this buffer as a
2-byte value, high byte first. |
ByteBuffer |
append(char[] array)
Appends the specified
char[] array to this buffer. |
ByteBuffer |
append(char[] array,
int offset,
int count)
Appends the specified number of elements from the specified
char[] array starting from the specified offset to this
buffer. |
ByteBuffer |
append(double value)
Appends the specified
double value to this buffer as a
8-byte quantity, high byte first. |
ByteBuffer |
append(double[] array)
Appends the specified
double[] array to this buffer. |
ByteBuffer |
append(double[] array,
int offset,
int count)
Appends the specified number of elements from the specified
double[] array starting from the specified offset to this
buffer. |
ByteBuffer |
append(float value)
Appends the specified
float value to this buffer as a
4-byte quantity, high byte first. |
ByteBuffer |
append(float[] array)
Appends the specified
float[] array to this buffer. |
ByteBuffer |
append(float[] array,
int offset,
int count)
Appends the specified number of elements from the specified
float[] array starting from the specified offset to this
buffer. |
ByteBuffer |
append(int value)
Appends the specified
int value to this buffer as four
bytes, high byte first. |
ByteBuffer |
append(int[] array)
Appends the specified
int[] array to this buffer. |
ByteBuffer |
append(int[] array,
int offset,
int count)
Appends the specified number of elements from the specified
int[] array starting from the specified offset to this
buffer. |
ByteBuffer |
append(long value)
Appends the specified
long value to this buffer as eight
bytes, high byte first. |
ByteBuffer |
append(long[] array)
Appends the specified
long[] array to this buffer. |
ByteBuffer |
append(long[] array,
int offset,
int count)
Appends the specified number of elements from the specified
long[] array starting from the specified offset to this
buffer. |
ByteBuffer |
append(short value)
Appends the specified
short value to this buffer as two
bytes, high byte first. |
ByteBuffer |
append(short[] array)
Appends the specified
short[] array to this buffer. |
ByteBuffer |
append(short[] array,
int offset,
int count)
Appends the specified number of elements from the specified
short[] array starting from the specified offset to this
buffer. |
void |
ensureCapacity(int capacity)
Increases the capacity of this buffer if necessary.
|
byte[] |
getBytes()
Returns array of bytes from this buffer.
|
int |
length()
Returns the number of valid bytes in this buffer.
|
void |
reset()
Clears this buffer.
|
protected byte[] data
protected int length
public ByteBuffer()
ByteBuffer with default initial capacity.public ByteBuffer(int capacity)
ByteBuffer with the specified initial
capacity.capacity - Initial capacity of the buffer.public ByteBuffer(byte[] array)
ByteBuffer with the specified initial data.array - Initial data.public ByteBuffer(byte[] array,
int offset,
int count)
ByteBuffer with the specified initial data.array - Initial data.offset - Start offset in the data.count - Number of bytes to copy.public int length()
public ByteBuffer append(byte value)
byte value to this buffer.value - byte value to append.public ByteBuffer append(byte[] array)
byte[] array to this buffer.array - byte[] array to append.append(byte[], int, int)public ByteBuffer append(byte[] array, int offset, int count)
byte[] array starting from the specified offset to this
buffer.array - byte[] array to append.offset - Start offset in the specified array.count - Number of elements to append.public ByteBuffer append(short value)
short value to this buffer as two
bytes, high byte first.value - short value to append.public ByteBuffer append(short[] array)
short[] array to this buffer.array - short[] array to append.append(short[], int, int)public ByteBuffer append(short[] array, int offset, int count)
short[] array starting from the specified offset to this
buffer.array - short[] array to append.offset - Start offset in the specified array.count - Number of elements to append.append(short)public ByteBuffer append(int value)
int value to this buffer as four
bytes, high byte first.value - int value to append.public ByteBuffer append(int[] array)
int[] array to this buffer.array - int[] array to append.append(int[], int, int)public ByteBuffer append(int[] array, int offset, int count)
int[] array starting from the specified offset to this
buffer.array - int[] array to append.offset - Start offset in the specified array.count - Number of elements to append.append(int)public ByteBuffer append(long value)
long value to this buffer as eight
bytes, high byte first.value - long value to append.public ByteBuffer append(long[] array)
long[] array to this buffer.array - long[] array to append.append(long[], int, int)public ByteBuffer append(long[] array, int offset, int count)
long[] array starting from the specified offset to this
buffer.array - long[] array to append.offset - Start offset in the specified array.count - Number of elements to append.append(long)public ByteBuffer append(float value)
float value to this buffer as a
4-byte quantity, high byte first.value - float value to append.append(int)public ByteBuffer append(float[] array)
float[] array to this buffer.array - float[] array to append.append(float[], int, int)public ByteBuffer append(float[] array, int offset, int count)
float[] array starting from the specified offset to this
buffer.array - float[] array to append.offset - Start offset in the specified array.count - Number of elements to append.append(int)public ByteBuffer append(double value)
double value to this buffer as a
8-byte quantity, high byte first.value - double value to append.append(long)public ByteBuffer append(double[] array)
double[] array to this buffer.array - double[] array to append.append(double[], int, int)public ByteBuffer append(double[] array, int offset, int count)
double[] array starting from the specified offset to this
buffer.array - double[] array to append.offset - Start offset in the specified array.count - Number of elements to append.append(long)public ByteBuffer append(char value)
char value to this buffer as a
2-byte value, high byte first.value - char value to append.append(short)public ByteBuffer append(char[] array)
char[] array to this buffer.array - char[] array to append.append(char[], int, int)public ByteBuffer append(char[] array, int offset, int count)
char[] array starting from the specified offset to this
buffer.array - char[] array to append.offset - Start offset in the specified array.count - Number of elements to append.append(short)public ByteBuffer append(boolean value)
boolean value to this buffer as a
1-byte value. The value true is appended as 1,
the value false is appended as 0.value - boolean value to append.append(byte)public ByteBuffer append(boolean[] array)
boolean[] array to this buffer.array - boolean[] array to append.append(boolean[], int, int)public ByteBuffer append(boolean[] array, int offset, int count)
boolean[] array starting from the specified offset to this
buffer.array - boolean[] array to append.offset - Start offset in the specified array.count - Number of elements to append.append(byte)public ByteBuffer append(ByteBuffer buffer)
buffer - Buffer to append.public void reset()
public void ensureCapacity(int capacity)
capacity - Desired minimum capacity.public byte[] getBytes()
Copyright © 2010-2012 FoxLabs. All Rights Reserved.