Here you can find the source of fromHex(String bytesString)
public static byte[] fromHex(String bytesString)
//package com.java2s; //License from project: Open Source License public class Main { public static byte[] fromHex(String bytesString) { int len = bytesString.length() / 2; if (bytesString.length() % 2 != 0) { throw new IllegalArgumentException("Bytes Hex string length has to be even number"); }// w w w. ja v a 2 s . c o m byte[] out = new byte[len]; for (int i = 0; i < len; i++) { int pos = i * 2; byte b = (byte) Integer.valueOf(bytesString.substring(pos, pos + 2), 16).intValue(); out[i] = b; } return out; } }