Here you can find the source of hex2byte(byte[] b)
private static byte[] hex2byte(byte[] b)
//package com.java2s; public class Main { private static byte[] hex2byte(byte[] b) { if ((b.length % 2) != 0) throw new IllegalArgumentException(); byte[] b2 = new byte[b.length / 2]; for (int n = 0; n < b.length; n += 2) { String item = new String(b, n, 2); b2[n / 2] = (byte) Integer.parseInt(item, 16); }//from w ww. j a v a2s. c om return b2; } }