Java tutorial
//package com.java2s; public class Main { private static byte[] str2ByteArray(String hexStr) { int len = hexStr.length() / 2; byte[] arr = new byte[len]; for (int i = 0; i < len; i++) { arr[i] = (byte) Integer.parseInt(hexStr.substring(i * 2, i * 2 + 2), 16); } return arr; } }