ByteBuf buf = Unpooled.buffer(4); buf.writeInt(42);
ByteBuf buf = ... // reference to a ByteBuf instance int value = buf.readInt();This code reads an integer value from an existing ByteBuf. The io.netty.buffer package library provides a variety of other methods for working with ByteBufs, including slicing, copying, and concatenating. It also offers various utility methods for handling network byte order and managing buffers in a thread-safe manner.