ByteBuf buf = ByteBufAllocator.DEFAULT.heapBuffer(len)
ByteBuf buf = Unpooled.buffer(2 + length);
new String(buf.arrya())
buf .array()如果buf是直接内存则会报错,要使用:
if(in.isDirect()){
byte[] array = new byte[in.readableBytes()];
in.readBytes(array);
}
ByteBuf buf = ByteBufAllocator.DEFAULT.heapBuffer(len)
ByteBuf buf = Unpooled.buffer(2 + length);
new String(buf.arrya())
buf .array()如果buf是直接内存则会报错,要使用:
if(in.isDirect()){
byte[] array = new byte[in.readableBytes()];
in.readBytes(array);
}