Here you can find the source of fromHex(final String s)
public static byte[] fromHex(final String s)
//package com.java2s; public class Main { public static byte[] fromHex(final char[] hex) { final int length = hex.length / 2; final byte[] raw = new byte[length]; for (int i = 0; i < length; i++) { final int high = Character.digit(hex[i * 2], 16); final int low = Character.digit(hex[i * 2 + 1], 16); int value = (high << 4) | low; if (value > 127) { value -= 256;/*from www. j a va2 s . com*/ } raw[i] = (byte) value; } return raw; } public static byte[] fromHex(final String s) { return fromHex(s.replace(" ", "").toCharArray()); } }