Here you can find the source of fromHexString(final String str)
public static byte[] fromHexString(final String str)
//package com.java2s; //License from project: Apache License public class Main { private static final String ERROR_INPUT_STRING_NUM_CHARS = "Input string must contain an even number of characters"; private static final String STR_HEX_PREFIX = "0x"; public static byte[] fromHexString(final String str) { if ((str.length() % 2) != 0) throw new IllegalArgumentException(ERROR_INPUT_STRING_NUM_CHARS); byte[] result = new byte[str.length() / 2]; for (int i = 0; i < str.length() / 2; i++) { result[i] = (Integer.decode(STR_HEX_PREFIX + str.substring(i * 2, (i + 1) * 2))).byteValue(); }/*from ww w . j av a 2 s. com*/ return result; } }