public final class ByteBufferUtils extends Object
ByteBuffers.| Modifier and Type | Field and Description |
|---|---|
static ByteBuffer |
EMPTY_BUFFER
A handy constant to use for no-op send/receive calls.
|
| Modifier and Type | Method and Description |
|---|---|
static ByteBuffer |
accumulate(ByteBuffer src,
ByteBuffer dst)
Accumulate the given buffer into the current context.
|
static ByteBuffer |
duplicate(ByteBuffer buffer)
Duplicate a byte buffer for storing for future use.
|
static String |
getUTF8(ByteBuffer src)
Read from the source buffer a string that has been encoded in UTF-8 and prefixed by a two byte length.
|
static void |
put(ByteBuffer src,
ByteBuffer dst)
Transfer bytes from src to dst.
|
static void |
putUTF8(String src,
ByteBuffer dst)
Transfer a string into the destination buffer as a UTF-8 encoded string prefixed by a two byte length.
|
static ByteBuffer |
wrapUTF8(String string)
Wrap a string encoded as a UTF-8 string prefixed by a two byte length.
|
public static final ByteBuffer EMPTY_BUFFER
public static void put(ByteBuffer src, ByteBuffer dst)
src - the source.dst - the destination.public static void putUTF8(String src, ByteBuffer dst)
src - the string to encode and copy.dst - the destination.public static String getUTF8(ByteBuffer src)
src - the source buffer.BufferUnderflowException - if the source buffer has not got the full string.public static ByteBuffer wrapUTF8(String string)
string - the string.ByteBuffer containing the two byte length followed by the string encoded as UTF-8.public static ByteBuffer accumulate(ByteBuffer src, ByteBuffer dst)
src - the buffer to accumulatedst - the buffer to accumulate intodst or a new buffer if dst did not have sufficient
capacity)public static ByteBuffer duplicate(ByteBuffer buffer)
buffer - the buffer to duplicateCopyright © 2004–2017. All rights reserved.