sting转换16进制码

//字符转16进制
            //十六进制码格式
            char[] chars = "0123456789abcdef".toCharArray();
            StringBuilder sb = new StringBuilder("");
            byte[] bs = string.getBytes();
            int bit;
            for (int i = 0; i < bs.length; i++) {
                bit = (bs[i] & 0x0f0) >> 4;
                sb.append(chars[bit]);
                bit = bs[i] & 0x0f;
                sb.append(chars[bit]);
            }
            //控件赋值
           sixteenMa.setText(sb.toString().trim());

你可能感兴趣的:(sting转换16进制码)