首页 > 其他 > 详细

字符串转Hex编码

时间:2015-06-12 17:06:57      阅读:243      评论:0      收藏:0      [点我收藏+]
public static String toHex(String str){
        try {
            byte[] bytes = str.getBytes("GBK");
            StringBuilder sb = new StringBuilder(bytes.length * 2);
            //转换hex编码
            for (byte b : bytes) {
                sb.append(Integer.toHexString(b + 0x800).substring(1));
            }
            return sb.toString();
        } catch (UnsupportedEncodingException e) {
            log.error(e);
        }
        return null;
    }

 

字符串转Hex编码

原文:http://www.cnblogs.com/longzhaoyu/p/4571938.html

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