I wanted to print io.netty.buffer.ByteBuf as string. But io.netty.buffer.ByteBuf.array() throws exception as follows.
java.lang.UnsupportedOperationException: direct buffer at io.netty.buffer.PooledUnsafeDirectByteBuf.array(PooledUnsafeDirectByteBuf.java:343)
Could some one help me to get the byte[] from byte io.netty.buffer.ByteBuf.
Thanks.
OK, I have figured out a way to print the values. If anyone is interested,
byte[] bytes = new byte[buf.readableBytes()];
buf.duplicate().readBytes(bytes);
System.out.println(new String(bytes));