Create a ByteBuf in Netty 4.0

28,524

The documentation seems pretty clear to me:

Creation of a buffer

It is recommended to create a new buffer using the helper methods in Unpooled rather than calling an individual implementation's constructor.

Then in Unpooled, you've got options of wrapping or copying. For example:

Choose whichever method is appropriate based on whether you want changes made in the returned ByteBuf to be passed through to the original byte array/buffer.

Share:
28,524

Related videos on Youtube

Dennis
Author by

Dennis

Updated on February 13, 2020

Comments

  • Dennis
    Dennis over 4 years

    Two simple questions, which I am not able to solve by reading the documentation:

    1. I have a byte[]
      • How can i convert it to a ByteBuf?
    2. I have a NIO ByteBuffer
      • How can i convert it to a ByteBuf?
  • Ismail Yavuz
    Ismail Yavuz almost 7 years
    Example: Unpooled.wrappedBuffer(new byte[] { 0x0D, 0X0A })