How to get a byte array from ByteBuf efficiently in the code below? I need to get the array and then serialize it.
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(); } }