Here you can find the source of String2Byte(String hexString)
public static byte[] String2Byte(String hexString)
//package com.java2s; public class Main { public static byte[] String2Byte(String hexString) { if (hexString.length() % 2 == 1) return null; byte[] ret = new byte[hexString.length() / 2]; for (int i = 0; i < hexString.length(); i += 2) { ret[i / 2] = Integer.decode( "0x" + hexString.substring(i, i + 2)).byteValue(); }//from ww w. ja v a2s . c o m return ret; } }