public static void writeHexString(ByteBuffer buffer,String hexStr) throws IOException {
  char[] hexChars=hexStr.toCharArray();
  if ((hexChars.length % 2) != 0) {
    throw new IOException("Hex string length must be even");
  }
  for (int i=0; i < hexChars.length; i+=2) {
    String tmpStr=new String(hexChars,i,2);
    buffer.put((byte)Integer.parseInt(tmpStr,16));
  }
}

public static void writeHexString ( ByteBuffer buffer , String hexStr ) throws IOException { char [ ] hexChars = hexStr . toCharArray ( ) ; if ( ( hexChars . length % 2 ) != 0 ) { throw new IOException ( "Hex string length must be even" ) ; } for ( int i = 0 ; i < hexChars . length ; i += 2 ) { String tmpStr = new String ( hexChars , i , 2 ) ; buffer . put ( ( byte ) Integer . parseInt ( tmpStr , 16 ) ) ; } }
writes a sequence of hexidecimal values into the given buffer , where every two characters represent one byte value .
