您当前的位置: 首页 > 

小志的博客

暂无认证

  • 0浏览

    0关注

    1217博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Netty——ByteBuffer(字符串与 ByteBuffer相互转换示例)

小志的博客 发布时间:2022-07-24 20:51:31 ,浏览量:0

目录
    • 一、字符串转ByteBuffer示例
      • 1.1、字符串转ByteBuffer示例(1)
      • 1.2、字符串转ByteBuffer示例(2)
      • 1.3、字符串转ByteBuffer示例(3)
    • 二、ByteBuffer转字符串示例
      • 2.1、ByteBuffer转字符串示例(1)
      • 2.2、ByteBuffer转字符串示例(2)

一、字符串转ByteBuffer示例 1.1、字符串转ByteBuffer示例(1)
  • 工具类

    package com.example.nettytest.nio.day1;
    
    import io.netty.util.internal.StringUtil;
    
    import java.nio.ByteBuffer;
    
    import static io.netty.util.internal.MathUtil.isOutOfBounds;
    import static io.netty.util.internal.StringUtil.NEWLINE;
    
    public class ByteBufferUtil {
        private static final char[] BYTE2CHAR = new char[256];
        private static final char[] HEXDUMP_TABLE = new char[256 * 4];
        private static final String[] HEXPADDING = new String[16];
        private static final String[] HEXDUMP_ROWPREFIXES = new String[65536 >>> 4];
        private static final String[] BYTE2HEX = new String[256];
        private static final String[] BYTEPADDING = new String[16];
    
        static {
            final char[] DIGITS = "0123456789abcdef".toCharArray();
            for (int i = 0; i  4 & 0x0F];
                HEXDUMP_TABLE[(i             
关注
打赏
1661269038
查看更多评论
0.0415s