Here you can find the source of fromHex(String hexString)
public static byte[] fromHex(String hexString)
//package com.java2s; //License from project: Open Source License public class Main { public static byte[] fromHex(String hexString) { if (hexString == null) { return null; }// w w w .j a va2s. c o m int len = hexString.length(); if (len % 2 != 0) { throw new IllegalArgumentException(); } byte[] data = new byte[len / 2]; for (int i = 0; i < data.length; i++) { // String hexByte = hexString.substring(i * 2, i * 2 + 2); // // Integer num = Integer.decode("0x" + hexByte); // data[i] = num.byteValue(); data[i] = (byte) (Integer.parseInt(hexString.substring(i * 2, i * 2 + 2), 16) & 0xff); } return data; } }