Here you can find the source of hex2bytes(String hex)
public static byte[] hex2bytes(String hex)
//package com.java2s; public class Main { public static byte[] hex2bytes(String hex) { byte[] bytes = new byte[hex.length() / 2]; for (int i = 0; i < bytes.length; i++) { bytes[i] = (byte) Integer.parseInt( hex.substring(i * 2, (i + 1) * 2), 16); }// w ww. j a va2s.c o m return bytes; } }