static public String toHexString(final byte[] buf,int n){
  if (buf == null)   return "NULL";
  n=n < buf.length ? n : buf.length;
  final StringBuffer out=new StringBuffer();
  for (int i=0; i < n; i++) {
    final int v=buf[i] & 0xFF;
    out.append(HEX_CHAR_TABLE[v >>> 4]);
    out.append(HEX_CHAR_TABLE[v & 0xF]);
  }
  return out.toString();
}

static public String toHexString ( final byte [ ] buf , int n ) { if ( buf == null ) return "NULL" ; n = n < buf . length ? n : buf . length ; final StringBuffer out = new StringBuffer ( ) ; for ( int i = 0 ; i < n ; i ++ ) { final int v = buf [ i ] & 0xFF ; out . append ( HEX_CHAR_TABLE [ v > > > 4 ] ) ; out . append ( HEX_CHAR_TABLE [ v & 0xF ] ) ; } return out . toString ( ) ; }
utility to display byte array of maximum i bytes as hexstring .
