Here you can find the source of hexStr2ByteArr(String str)
public static byte[] hexStr2ByteArr(String str) throws Exception
//package com.java2s; public class Main { public static byte[] hexStr2ByteArr(String str) throws Exception { byte[] arrB = str.getBytes(); int iLen = arrB.length; byte[] arrOut = new byte[iLen / 2]; for (int i = 0; i < iLen; i = i + 2) { String strTmp = new String(arrB, i, 2); arrOut[i / 2] = (byte) Integer.parseInt(strTmp, 16); }/*from w w w. ja v a 2s . co m*/ return arrOut; } }