Java tutorial
//package com.java2s; public class Main { public static String decodeHexString(char[] data) { return new String(decodeHex(data)); } public static byte[] decodeHex(char[] data) { int len = data.length; if ((len & 1) != 0) { return null; } else { byte[] out = new byte[len >> 1]; int i = 0; for (int j = 0; j < len; ++i) { int f = toDigit(data[j], j) << 4; ++j; f |= toDigit(data[j], j); ++j; out[i] = (byte) (f & 255); } return out; } } protected static int toDigit(char ch, int index) { int digit = Character.digit(ch, 16); if (digit == -1) { return 0; } else { return digit; } } }