Here you can find the source of fromHexString(String hex)
public static byte[] fromHexString(String hex)
//package com.java2s; //License from project: Open Source License public class Main { public static byte[] fromHexString(String hex) { return fromHex(hex.getBytes()); }//from w w w . j a va 2 s. co m public static byte[] fromHex(byte[] sc) { byte[] res = new byte[sc.length / 2]; for (int i = 0; i < sc.length; i++) { byte c1 = (byte) (sc[i] - 48 < 17 ? sc[i] - 48 : sc[i] - 55); i++; byte c2 = (byte) (sc[i] - 48 < 17 ? sc[i] - 48 : sc[i] - 55); res[i / 2] = (byte) (c1 * 16 + c2); } return res; } }