Java HEX字符串和byte[]互相转换

package com.wxy.Utils;


public class HexTool {
    static public byte hexStrToByte(String hexbytein){
        return (byte)Integer.parseInt(hexbytein,16);
    }

    public static byte [] Str2Hex(String hexStrIn){
        int hexlen = hexStrIn.length()/2;
        byte [] result;
        result = new byte[hexlen];
        for (int i = 0; i < hexlen; i++){
            result[i]=hexStrToByte(hexStrIn.substring(i*2,i*2+2));
        }
        return result;
    }

    public  static String Hex2Str(byte[] hexByteIn){
        int len = hexByteIn.length;
        String restult = new String();
        for(int i =0;i 
 

你可能感兴趣的:(Java HEX字符串和byte[]互相转换)