Here you can find the source of fromHex(String hex)
public static byte[] fromHex(String hex)
//package com.java2s; //License from project: Apache License public class Main { public static byte[] fromHex(String hex) { if (hex != null && hex.length() > 1) { try { byte bytes[] = new byte[hex.length() / 2]; for (int i = 0; i < bytes.length; i++) { bytes[i] = (byte) Integer.parseInt(hex.substring(i << 1, (i << 1) + 2), 16); }/*from ww w .j a va2s . co m*/ return bytes; } catch (Throwable e) { e.printStackTrace(); } } return null; } }