package tju.SpringBootPostServer.controller;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.util.CharsetUtil;
public class TestMe {
public static void main(String[] args) throws UnsupportedEncodingException {
ByteBuf byteBuf = Unpooled.copiedBuffer("current time is: "+new Date(),CharsetUtil.UTF_8);
byte[] bytes = new byte[byteBuf.readableBytes()];
byteBuf.readBytes(bytes);
String body = new String(bytes,"UTF-8");
System.out.println(body);
}
}
Netty: ByteBuf转String
猜你喜欢
转载自blog.csdn.net/amadeus_liu2/article/details/115174549
今日推荐
周排行