首页 > 其他 > 详细

16进制的字符串转化为utf-8格式的字符串

时间:2019-01-30 13:46:13      阅读:197      评论:0      收藏:0      [点我收藏+]
    /**
     * 16进制的字符串转化为utf-8格式的字符串
     * @param s
     * @return
     */
    public static String toStringHex(String s) {
        byte[] baKeyword = new byte[s.length() / 2];
        for (int i = 0; i < baKeyword.length; i++) {
        try {
        baKeyword[i] = (byte) (0xff & Integer.parseInt(s.substring(
        i * 2, i * 2 + 2), 16));
        } catch (Exception e) {
        e.printStackTrace();
        }
        }
        try {
        s = new String(baKeyword, "utf-8");// UTF-16le:Not
        } catch (Exception e1) {
        e1.printStackTrace();
        }
        return s;
    }

 

16进制的字符串转化为utf-8格式的字符串

原文:https://www.cnblogs.com/huyanlon/p/10337636.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!