A buffer whose capacity is {@code 0}.
Creates a new big-endian heap buffer with reasonably small initial capacity, which expands its capacity boundlessly on demand.
Creates a new big-endian heap buffer with the specified {@code capacity}, which expands its capacity boundlessly on demand. The new buffer's {@code readerIndex} and {@code writerIndex} are {@code 0}.
Creates a new big-endian heap buffer with the specified {@code initialCapacity}, that may grow up to {@code maxCapacity} The new buffer's {@code readerIndex} and {@code writerIndex} are {@code 0}.
Returns a new big-endian composite buffer with no components.
Returns a new big-endian composite buffer with no components.
Creates a new big-endian buffer whose content is a copy of the specified {@code array}. The new buffer's {@code readerIndex} and {@code writerIndex} are {@code 0} and {@code array.length} respectively.
Creates a new big-endian buffer whose content is a copy of the specified {@code array}'s sub-region. The new buffer's {@code readerIndex} and {@code writerIndex} are {@code 0} and the specified {@code length} respectively.
Creates a new buffer whose content is a copy of the specified {@code buffer}'s current slice. The new buffer's {@code readerIndex} and {@code writerIndex} are {@code 0} and {@code buffer.remaining} respectively.
Creates a new buffer whose content is a copy of the specified {@code buffer}'s readable bytes. The new buffer's {@code readerIndex} and {@code writerIndex} are {@code 0} and {@code buffer.readableBytes} respectively.
Creates a new big-endian buffer whose content is a merged copy of the specified {@code arrays}. The new buffer's {@code readerIndex} and {@code writerIndex} are {@code 0} and the sum of all arrays' {@code length} respectively.
Creates a new buffer whose content is a merged copy of the specified {@code buffers}' readable bytes. The new buffer's {@code readerIndex} and {@code writerIndex} are {@code 0} and the sum of all buffers' {@code readableBytes} respectively.
Creates a new buffer whose content is a merged copy of the specified {@code buffers}' slices. The new buffer's {@code readerIndex} and {@code writerIndex} are {@code 0} and the sum of all buffers' {@code remaining} respectively.
Creates a new big-endian buffer whose content is the specified {@code string} encoded in the specified {@code charset}. The new buffer's {@code readerIndex} and {@code writerIndex} are {@code 0} and the length of the encoded string respectively.
Creates a new big-endian buffer whose content is the specified {@code array} encoded in the specified {@code charset}. The new buffer's {@code readerIndex} and {@code writerIndex} are {@code 0} and the length of the encoded string respectively.
Creates a new big-endian buffer whose content is a subregion of the specified {@code array} encoded in the specified {@code charset}. The new buffer's {@code readerIndex} and {@code writerIndex} are {@code 0} and the length of the encoded string respectively.
Creates a new single-byte big-endian buffer that holds the specified bool value.
Create a new big-endian buffer that holds a sequence of the specified bool values.
Create a new big-endian buffer that holds a sequence of the specified 64-bit floating point numbers.
Create a new big-endian buffer that holds a sequence of the specified 32-bit floating point numbers.
Creates a new 4-byte big-endian buffer that holds the specified 32-bit integer.
Create a big-endian buffer that holds a sequence of the specified 32-bit integers.
Create a new big-endian buffer that holds a sequence of the specified 64-bit integers.
Creates a new 3-byte big-endian buffer that holds the specified 24-bit integer.
Create a new big-endian buffer that holds a sequence of the specified 24-bit integers.
Create a new big-endian buffer that holds a sequence of the specified 16-bit integers.
Creates a new big-endian direct buffer with reasonably small initial capacity, which expands its capacity boundlessly on demand.
Creates a new big-endian direct buffer with the specified {@code capacity}, which expands its capacity boundlessly on demand. The new buffer's {@code readerIndex} and {@code writerIndex} are {@code 0}.
Creates a new big-endian direct buffer with the specified {@code initialCapacity}, that may grow up to {@code maxCapacity}. The new buffer's {@code readerIndex} and {@code writerIndex} are {@code 0}.
Creates a new big-endian buffer which wraps the specified {@code array}. A modification on the specified array's content will be visible to the returned buffer.
Creates a new big-endian buffer which wraps the sub-region of the specified {@code array}. A modification on the specified array's content will be visible to the returned buffer.
Creates a new buffer which wraps the specified NIO buffer's current slice. A modification on the specified buffer's content will be visible to the returned buffer.
Creates a new buffer which wraps the specified buffer's readable bytes. A modification on the specified buffer's content will be visible to the returned buffer. @param buffer The buffer to wrap. Reference count ownership of this variable is transferred to this method. @return The readable portion of the {@code buffer}, or an empty buffer if there is no readable portion. The caller is responsible for releasing this buffer.
Creates a new big-endian composite buffer which wraps the specified arrays without copying them. A modification on the specified arrays' content will be visible to the returned buffer.
Creates a new big-endian composite buffer which wraps the readable bytes of the specified buffers without copying them. A modification on the content of the specified buffers will be visible to the returned buffer. @param buffers The buffers to wrap. Reference count ownership of all variables is transferred to this method. @return The readable portion of the {@code buffers}. The caller is responsible for releasing this buffer.
Creates a new big-endian composite buffer which wraps the slices of the specified NIO buffers without copying them. A modification on the content of the specified buffers will be visible to the returned buffer.
Creates a new big-endian composite buffer which wraps the specified arrays without copying them. A modification on the specified arrays' content will be visible to the returned buffer.
Creates a new big-endian composite buffer which wraps the readable bytes of the specified buffers without copying them. A modification on the content of the specified buffers will be visible to the returned buffer. @param maxNumComponents Advisement as to how many independent buffers are allowed to exist before consolidation occurs. @param buffers The buffers to wrap. Reference count ownership of all variables is transferred to this method. @return The readable portion of the {@code buffers}. The caller is responsible for releasing this buffer.
Creates a new big-endian composite buffer which wraps the slices of the specified NIO buffers without copying them. A modification on the content of the specified buffers will be visible to the returned buffer.
Wrap the given {@link ByteBuf}s in an unmodifiable {@link ByteBuf}. Be aware the returned {@link ByteBuf} will not try to slice the given {@link ByteBuf}s to reduce GC-Pressure.
Big endian byte order.
Little endian byte order.
Creates a new {@link ByteBuf} by allocating new space or by wrapping or copying existing byte arrays, byte buffers and a string.
<h3>Use static import</h3> This classes is intended to be used with Java 5 static import statement:
<pre> import static io.netty.buffer.{@link Unpooled}.*;
{@link ByteBuf} heapBuffer = buffer(128); {@link ByteBuf} directBuffer = directBuffer(256); {@link ByteBuf} wrappedBuffer = wrappedBuffer(new byte[128], new byte[256]); {@link ByteBuf} copiedBuffer = copiedBuffer({@link ByteBuffer}.allocate(128)); </pre>
<h3>Allocating a new buffer</h3>
Three buffer types are provided out of the box.
<ul> <li>{@link #buffer(int)} allocates a new fixed-capacity heap buffer.</li> <li>{@link #directBuffer(int)} allocates a new fixed-capacity direct buffer.</li> </ul>
<h3>Creating a wrapped buffer</h3>
Wrapped buffer is a buffer which is a view of one or more existing byte arrays and byte buffers. Any changes in the content of the original array or buffer will be visible in the wrapped buffer. Various wrapper methods are provided and their name is all {@code wrappedBuffer()}. You might want to take a look at the methods that accept varargs closely if you want to create a buffer which is composed of more than one array to reduce the number of memory copy.
<h3>Creating a copied buffer</h3>
Copied buffer is a deep copy of one or more existing byte arrays, byte buffers or a string. Unlike a wrapped buffer, there's no shared data between the original data and the copied buffer. Various copy methods are provided and their name is all {@code copiedBuffer()}. It is also convenient to use this operation to merge multiple buffers into one buffer.