public final class ByteBuffer extends Object implements Iterable<Byte>, Serializable
| Constructor and Description |
|---|
ByteBuffer()
Creates a new
ByteBuffer with an initial capacity of 512
bytes. |
ByteBuffer(byte... bytes)
Creates a new
ByteBuffer containing the given data. |
ByteBuffer(int capacity)
Creates a new
ByteBuffer having the given initial capacity. |
| Modifier and Type | Method and Description |
|---|---|
ByteBuffer |
append(byte... bytes)
Writes the given bytes to this buffer.
|
ByteBuffer |
append(byte b)
Writes the given byte to this buffer.
|
ByteBuffer |
append(byte[] bytes,
int off,
int len)
Writes the given data to this buffer.
|
ByteBuffer |
clear()
Clears this buffer.
|
boolean |
equals(Object o) |
int |
hashCode() |
Iterator<Byte> |
iterator() |
int |
size()
Returns the number of bytes contained in this buffer.
|
byte[] |
toByteArray()
Returns the content of this buffer.
|
byte[] |
toByteArray(int off)
Returns the bytes contained in this buffer, starting at
off. |
byte[] |
toByteArray(int off,
int len)
Returns
len bytes from this buffer, starting at off. |
String |
toString() |
public ByteBuffer()
ByteBuffer with an initial capacity of 512
bytes.public ByteBuffer(int capacity)
ByteBuffer having the given initial capacity.capacity - the initial capacity.IllegalArgumentException - if capacity < 0.public ByteBuffer(byte... bytes)
ByteBuffer containing the given data.bytes - the buffer's initial content.NullPointerException - if bytes is null.public ByteBuffer append(byte b)
b - the byte to write.public ByteBuffer append(byte... bytes)
bytes - the bytes to write.NullPointerException - if bytes is null.public ByteBuffer append(byte[] bytes, int off, int len)
bytes - the data to write.off - the offset.len - the number of bytes to write.NullPointerException - if bytes is null.IndexOutOfBoundsException - if off or len is
negative or if off + len is greater than the length of
the bytes array.public ByteBuffer clear()
public int size()
public byte[] toByteArray()
public byte[] toByteArray(int off)
off.off - the starting offset.IndexOutOfBoundsException - if off is negative or
if off is greater than size().public byte[] toByteArray(int off,
int len)
len bytes from this buffer, starting at off.off - the starting offset.len - the number of bytes to return.IndexOutOfBoundsException - if off or len is
negative or if off + len is greater than size().Copyright © 2012–2015. All rights reserved.