title: Netty java getting data from ByteBuf
body: <p>How to get a byte array from <code>ByteBuf</code> efficiently in the code below? I need to get the array and then serialize it.</p>
  
  <pre><code>package testingNetty;
  import io.netty.buffer.ByteBuf;
  import io.netty.channel.ChannelHandlerContext;
  import io.netty.channel.ChannelInboundHandlerAdapter;
  
  public class ServerHandler extends  ChannelInboundHandlerAdapter {
       @Override
          public void channelRead(ChannelHandlerContext ctx, Object msg) {
           System.out.println("Message receive");
           ByteBuf buff = (ByteBuf) msg;
               // There is I need get bytes from buff and make serialization
           byte[] bytes = BuffConvertor.GetBytes(buff);
          }
  
          @Override
          public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { 
              // Close the connection when an exception is raised.
              cause.printStackTrace();
              ctx.close();
          }
  
  }
  </code></pre>