ByteBuf buffer = Unpooled.buffer(4); buffer.writeByte(0xFF);
ByteBuf buffer = Unpooled.buffer(8); for (int i = 0; i < 8; i++) { byte b = (byte) (i + 1); buffer.writeByte(b); }In this example, a new ByteBuf is created with a capacity of eight bytes. A for loop is used to write the numbers 1-8 to the buffer as bytes. The examples use the package library io.netty.buffer, which provides classes for handling low-level network data. The Unpooled static class is also used to create new ByteBuf objects.