public class BufUtils extends Object
Constructor and Description |
---|
BufUtils() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
getBytes(io.netty.buffer.ByteBuf buf)
Create a copy of the underlying storage from
buf into a byte array. |
static byte[] |
getBytes(io.netty.buffer.ByteBuf buf,
int start,
int length)
Create a copy of the underlying storage from
buf into a byte array. |
static byte[] |
getBytes(io.netty.buffer.ByteBuf buf,
int start,
int length,
boolean copy)
Return an array of the underlying storage from
buf into a byte array. |
public static byte[] getBytes(io.netty.buffer.ByteBuf buf)
buf
into a byte array.
The copy will start at ByteBuf.readerIndex()
and copy
ByteBuf.readableBytes()
bytes.buf
- Buffer that contains all bytespublic static byte[] getBytes(io.netty.buffer.ByteBuf buf, int start, int length)
buf
into a byte array.
The copy will start at start
and copy length
bytes.buf
- Buffer that contains all bytesstart
- the start index of byteslength
- the length of bytespublic static byte[] getBytes(io.netty.buffer.ByteBuf buf, int start, int length, boolean copy)
buf
into a byte array.
The copy will start at start
and copy length
bytes. If
copy
is true a copy will be made of the memory. If copy
is
false the underlying storage will be shared, if possible.buf
- Buffer that contains all bytesstart
- the start index of byteslength
- the length of bytescopy
- true if should copy the content from buffer (and don't change the index)