public class Buffer extends Object
| Constructor and Description |
|---|
Buffer()
Creates an unitialized buffer.
|
Buffer(int capacity)
Creates an initialized buffer with the specified capacity.
|
| Modifier and Type | Method and Description |
|---|---|
void |
ensureCapacity(int capacity)
Ensures that the buffer has a capacity to store the number
of bytes.
|
byte[] |
getData()
Returns the byte array used as a backing store for this
buffer.
|
int |
getLength()
Returns the length of this buffer.
|
void |
setLength(int length)
Sets the length of this buffer.
|
byte[] |
toByteArray()
Returns a copy of the buffers internal array in a newly allocated
byte array with the buffer's length.
|
public Buffer()
public Buffer(int capacity)
capacity - initial buffer length in bytespublic void ensureCapacity(int capacity)
capacity - buffer length in bytespublic byte[] getData()
public int getLength()
public void setLength(int length)
throws IllegalStateException,
IllegalArgumentException
length - buffer lengthIllegalStateException - if the buffer is not yet initializedIllegalArgumentException - if the requested length exceeds the buffers capacitypublic byte[] toByteArray()
Copyright © 2014 AVAST Software. All Rights Reserved.