Here you can find the source of asBytes(String hexStr)
public static byte[] asBytes(String hexStr)
//package com.java2s; //License from project: Open Source License public class Main { public static byte[] asBytes(String hexStr) { if (hexStr.length() < 1) { return null; }//w w w .ja v a2s .co m byte[] result = new byte[hexStr.length() / 2]; int high, low; for (int i = 0; i < hexStr.length() / 2; i++) { high = Integer.parseInt(hexStr.substring(i * 2, i * 2 + 1), 16); low = Integer.parseInt(hexStr.substring(i * 2 + 1, i * 2 + 2), 16); result[i] = (byte) (high * 16 + low); } return result; } }