public static byte[] hexStringToBytes(String hexString){
  byte[] data=new byte[hexString.length() / 2];
  for (int i=0; i < data.length; i++) {
    String a=hexString.substring(i * 2,i * 2 + 2);
    data[i]=(byte)Integer.parseInt(a,16);
  }
  return data;
}

public static byte [ ] hexStringToBytes ( String hexString ) { byte [ ] data = new byte [ hexString . length ( ) / 2 ] ; for ( int i = 0 ; i < data . length ; i ++ ) { String a = hexString . substring ( i * 2 , i * 2 + 2 ) ; data [ i ] = ( byte ) Integer . parseInt ( a , 16 ) ; } return data ; }
converts a string of hex characters to a byte array .
