Here you can find the source of toByteArray(String hexString)
public static byte[] toByteArray(String hexString)
//package com.java2s; //License from project: Apache License public class Main { /**//from ww w .java2 s . c o m * Get byte array from hex string */ public static byte[] toByteArray(String hexString) { int arrLength = hexString.length() >> 1; byte buff[] = new byte[arrLength]; for (int i = 0; i < arrLength; i++) { int index = i << 1; String digit = hexString.substring(index, index + 2); buff[i] = (byte) Integer.parseInt(digit, 16); } return buff; } }