Here you can find the source of toBytes(String hexStr)
public static byte[] toBytes(String hexStr)
//package com.java2s; /*/* w w w. ja va 2s. c o m*/ * Author : Ardika Rommy Sanjaya * Website : http://ardikars.com * Contact : contact@ardikars.com * License : Lesser GNU Public License Version 3 */ public class Main { public static byte[] toBytes(String hexStr) { String src = hexStr.replaceAll("\\s+", "").trim(); int len = src.length(); byte[] data = new byte[len / 2]; for (int i = 0; i < len; i += 2) { data[i / 2] = (byte) ((Character.digit(src.charAt(i), 16) << 4) + Character.digit(src.charAt(i + 1), 16)); } return data; } }