public final class BufferUtils extends Object
Modifier and Type | Method and Description |
---|---|
static ByteBuffer |
ensureCapacity(ByteBuffer buffer,
int capacity)
Ensure the byte buffer's capacity.
|
static CharBuffer |
ensureCapacity(CharBuffer buffer,
int capacity)
Ensure the char buffer's capacity.
|
static byte[] |
toArray(ByteBuffer buffer) |
static String |
toString(ByteBuffer buffer,
Charset charset) |
public static ByteBuffer ensureCapacity(ByteBuffer buffer, int capacity)
capacity
- The required capacity of the buffer.buffer
- The buffer to check or null
if a new buffer should be
allocated.public static CharBuffer ensureCapacity(CharBuffer buffer, int capacity)
capacity
- The required capacity of the buffer.buffer
- The buffer to check or null
if a new buffer should be
allocated.public static String toString(ByteBuffer buffer, Charset charset)
buffer
- The buffer to convert to a string.charset
- The charset to use when converting bytes to characters.public static byte[] toArray(ByteBuffer buffer)
buffer
- The buffer to read from.Copyright © 2016. All rights reserved.