Here you can find the source of hexToBytes(String hexStr)
public static byte[] hexToBytes(String hexStr)
//package com.java2s; //License from project: Apache License import java.nio.ByteBuffer; public class Main { public static byte[] hexToBytes(String hexStr) { ByteBuffer bytes = ByteBuffer.allocate(hexStr.length() / 2); for (int i = 0; i < hexStr.length(); i += 2) { Byte b = (byte) (0xff & Integer.parseInt(hexStr.substring(i, i + 2), 16)); bytes.put(b);// w w w. j a v a2s. co m } return bytes.array(); } }