Java tutorial
//package com.java2s; public class Main { public static byte[] stringToBytes(String in) { int length = in.length() / 2; byte[] b = new byte[length]; for (int i = 0; i < length; i++) { b[i] = Integer.valueOf(in.substring(i * 2, i * 2 + 2), 16).byteValue(); } return b; } }