Here you can find the source of hexStringToBytes(String hex)
public static byte[] hexStringToBytes(String hex)
//package com.java2s; public class Main { public static byte[] hexStringToBytes(String hex) { if (0 != hex.length() % 2) throw new IllegalArgumentException(hex + " not be a valid HEX String!"); byte[] result = new byte[hex.length() >> 1]; int high_nibble; int low_nibble; for (int i = 0, j = 0; i < result.length; i++, j += 2) { high_nibble = Character.digit(hex.charAt(j), 16) << 4; low_nibble = Character.digit(hex.charAt(j + 1), 16); result[i] = (byte) (high_nibble + low_nibble); }/*from w w w . ja va 2 s . c o m*/ return result; } }