Here you can find the source of fromHexString(String input)
public static byte[] fromHexString(String input)
//package com.java2s; //License from project: Open Source License public class Main { public static byte[] fromHexString(String input) { if (input == null || input.trim().length() == 0 || input.trim().length() % 2 != 0) { throw new IllegalArgumentException( "Input " + input + " is not valid. Must be not empty and length%2=0"); }// www . j a v a2 s . c om byte[] result = new byte[input.length() / 2]; for (int i = 0; i < input.length(); i += 2) { int intValue = Integer.valueOf(input.substring(i, i + 2), 16); result[i / 2] = (byte) (0x000000ff & intValue); } return result; } }