Here you can find the source of hexDecode(String str, byte[] ba, int len)
public static void hexDecode(String str, byte[] ba, int len)
//package com.java2s; public class Main { public static void hexDecode(String str, byte[] ba, int len) { char[] cp = str.toCharArray(); byte nbl = 0; int i = 0; int icp = 0; int iba = 0; for (; i < len; i++, icp++) { if (cp[icp] >= '0' && cp[icp] <= '9') nbl = (byte) (cp[icp] - '0'); else if (cp[icp] >= 'A' && cp[icp] <= 'F') nbl = (byte) (cp[icp] - 'A' + 10); else if (cp[icp] >= 'a' && cp[icp] <= 'f') nbl = (byte) (cp[icp] - 'a' + 10); if ((i & 0x1) == 0) ba[iba] = (byte) (nbl << 4); else/*from www. j a v a 2s .c o m*/ ba[iba++] |= nbl; } } }