Search in sources :

Example 1 with UnpooledByteBufAllocator

use of com.generallycloud.baseio.buffer.UnpooledByteBufAllocator in project baseio by generallycloud.

the class TestUnpooledByteBufAllocator method test.

static void test() {
    UnpooledByteBufAllocator allocator = UnpooledByteBufAllocator.getDirect();
    byte[] data = "你好啊,world".getBytes();
    ByteBuf buf = allocator.allocate(data.length);
    buf.put(data);
    buf.flip();
    ReleaseUtil.release(buf);
    for (; ; ) {
        ByteBuf buf2 = buf.duplicate();
        byte[] bb = buf2.getBytes();
        String s = new String(bb);
        System.out.println(s);
    }
}
Also used : UnpooledByteBufAllocator(com.generallycloud.baseio.buffer.UnpooledByteBufAllocator) ByteBuf(com.generallycloud.baseio.buffer.ByteBuf)

Aggregations

ByteBuf (com.generallycloud.baseio.buffer.ByteBuf)1 UnpooledByteBufAllocator (com.generallycloud.baseio.buffer.UnpooledByteBufAllocator)1