用ByteBufUtil的hexDump(byte[] array)函数将字节数组的内容转换为十六进制表示的字符串
package com.thb;import io.netty.buffer.ByteBufUtil;public class Demo {public static void main(String[] args) {byte[] b = new byte[] {0x68, 0x16, 0x03, 0x04, (byte)0xae};String hexDump = ByteBufUtil.hexDump(b);System.out.println(hexDump);}}
运行输出:
用ByteBufUtil的hexDump(ByteBuf buffer)函数将ByteBuf 的内容转换为十六进制表示的字符串
package com.thb;import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
import io.netty.buffer.Unpooled;public class Demo {public static void main(String[] args) {byte[] b = new byte[] {0x68, 0x16, 0x03, 0x04, (byte)0xae};// 用字节数组的内容创建一个ByteBufByteBuf buf = Unpooled.copiedBuffer(b);String hexDump = ByteBufUtil.hexDump(buf);System.out.println(hexDump);}}
运行输出: