feat(新增): 🚀 ByteBufDemo学习

This commit is contained in:
bunny 2024-05-24 10:40:55 +08:00
parent d7212c4d0a
commit ce650bd4ea
1 changed files with 18 additions and 0 deletions

View File

@ -0,0 +1,18 @@
package cn.bunny.service.netty.demo6;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
public class ByteBufDemo {
public static void main(String[] args) {
ByteBuf buf = ByteBufAllocator.DEFAULT.buffer();
System.out.println(buf);
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < 300; i++) {
stringBuilder.append("a");
}
buf.writeBytes(stringBuilder.toString().getBytes());
System.out.println(buf);
}
}