1.byteBuf创建方法
2.自动动态扩容的
package com.xkj.bound;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class TestByteBuf {
public static void main(String[] args) {
//bytebuf可以不指定容量,默认是256
//bytebuf是可以自动动态扩容
ByteBuf buf = ByteBufAllocator.DEFAULT.buffer();
log.debug("buf={}", buf);
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < 300; i++) {
stringBuilder.append("a");
}
buf.writeBytes(stringBuilder.toString().getBytes());
log.debug("buf={}", buf);
}
}
查看bytebuf更丰富的日志log方法:
import static io.n