public class ByteBuffer extends Object
Modifier and Type | Field and Description |
---|---|
protected int |
capacityIncrement
The amount by which the capacity of the ByteBuffer is automatically
incremented when its size becomes greater than its capacity.
|
protected int |
elementCount
The number of valid components in this ByteBuffer object.
|
protected byte[] |
elementData
The array buffer into which the components of the ByteBuffer are
stored.
|
Constructor and Description |
---|
ByteBuffer()
Constructs an empty ByteBuffer so that its internal data array
has size 10 and its standard capacity increment is
zero.
|
ByteBuffer(int initialCapacity)
Constructs an empty ByteBuffer with the specified initial capacity and
with its capacity increment equal to zero.
|
ByteBuffer(int initialCapacity,
int capacityIncrement)
Constructs an empty ByteBuffer with the specified initial capacity and
capacity increment.
|
Modifier and Type | Method and Description |
---|---|
void |
append(byte value) |
void |
append(int value) |
void |
append(String value) |
int |
capacity()
Returns the current capacity of this ByteBuffer.
|
boolean |
isEmpty()
Tests if this ByteBuffer has no components.
|
int |
size()
Returns the number of components in this ByteBuffer.
|
byte[] |
toArray()
Returns an array containing all of the elements in this ByteBuffer
in the correct order.
|
void |
trimToSize()
Trims the capacity of this ByteBuffer to be the ByteBuffer's current
size.
|
protected byte[] elementData
Any array elements following the last element in the ByteBuffer are 0.
protected int elementCount
protected int capacityIncrement
public ByteBuffer(int initialCapacity, int capacityIncrement)
initialCapacity
- the initial capacity of the ByteBuffer.capacityIncrement
- the amount by which the capacity is
increased when the ByteBuffer overflows.IllegalArgumentException
- if the specified initial capacity
is negativepublic ByteBuffer(int initialCapacity)
initialCapacity
- the initial capacity of the ByteBuffer.IllegalArgumentException
- if the specified initial capacity
is negativepublic ByteBuffer()
public void trimToSize()
public int capacity()
public int size()
public boolean isEmpty()
true
if and only if this ByteBuffer has
no components, that is, its size is zero;
false
otherwise.public void append(byte value)
public void append(int value)
public void append(String value)
public byte[] toArray()
Copyright © 2021 JBoss by Red Hat. All rights reserved.