public static byte[] hexStringToByteArray2(final String config){
  final int offset=4;
  final int len=config.length() / 2;
  final byte[] ret=new byte[len + 4];
  for (int i=offset; i < ret.length; i++) {
    final char first=config.charAt((i - offset) * 2);
    final char second=config.charAt((i - offset) * 2 + 1);
    int value=Integer.parseInt(new String(new byte[]{(byte)first}),16) << 4;
    value+=second;
    ret[i]=(byte)Integer.parseInt(new String(new byte[]{(byte)second}),16);
  }
  final DataBuffer databuffer=new DataBuffer(ret,0,4);
  databuffer.writeInt(len);
  return ret;
}

public static byte [ ] hexStringToByteArray2 ( final String config ) { final int offset = 4 ; final int len = config . length ( ) / 2 ; final byte [ ] ret = new byte [ len + 4 ] ; for ( int i = offset ; i < ret . length ; i ++ ) { final char first = config . charAt ( ( i - offset ) * 2 ) ; final char second = config . charAt ( ( i - offset ) * 2 + 1 ) ; int value = Integer . parseInt ( new String ( new byte [ ] { ( byte ) first } ) , 16 ) << 4 ; value += second ; ret [ i ] = ( byte ) Integer . parseInt ( new String ( new byte [ ] { ( byte ) second } ) , 16 ) ; } final DataBuffer databuffer = new DataBuffer ( ret , 0 , 4 ) ; databuffer . writeInt ( len ) ; return ret ; }
hex string to byte array2 .
