Java tutorial
//package com.java2s; public class Main { public static byte hexStringToByte(String hex) { byte result; if (hex.length() == 1) { hex = "0" + hex; } char[] achar = hex.toCharArray(); result = (byte) (toByte(achar[0]) << 4 | toByte(achar[1])); return result; } private static byte toByte(char c) { byte b = (byte) "0123456789ABCDEF".indexOf(c); return b; } }