Here you can find the source of hexToBytes(String hexString)
public static byte[] hexToBytes(String hexString)
//package com.java2s; public class Main { /**//from w w w . j ava2 s.c om * Takes a string in hexidecimal format and converts it to a binary byte * array. This does no checking of the format of the input, so this should * only be used after confirming the format or origin of the string. The input * string should only contain the hex data, two characters per byte. */ public static byte[] hexToBytes(String hexString) { byte[] result = new byte[hexString.length() / 2]; for (int i = 0; i < result.length; ++i) { int offset = i * 2; result[i] = (byte) Integer.parseInt( hexString.substring(offset, offset + 2), 16); } return result; } }