Here you can find the source of hexToBytes(String str)
public static byte[] hexToBytes(String str)
//package com.java2s; public class Main { public static byte[] hexToBytes(String str) { if (str == null) { return null; } else if (str.length() < 2) { return null; } else {/*from ww w .j a v a 2 s . com*/ int len = str.length() / 2; byte[] buffer = new byte[len]; for (int i = 0; i < len; i++) { buffer[i] = (byte) Integer.parseInt( str.substring(i * 2, i * 2 + 2), 16); } return buffer; } } }