public static String dumpHexBuffer(byte[] b,int offset,int len){
  StringBuffer buf=new StringBuffer(len << 1);
  int k=1;
  int flen=offset + len;
  for (int i=offset; i < flen; i++) {
    int j=b[i] & 0xFF;
    buf.append(Character.forDigit((j >>> 4),16));
    buf.append(Character.forDigit((j & 0x0F),16));
    k++;
    if (k % 16 == 0) {
      buf.append('\n');
      k=1;
    }
 else     buf.append(' ');
  }
  return buf.toString();
}

public static String dumpHexBuffer ( byte [ ] b , int offset , int len ) { StringBuffer buf = new StringBuffer ( len << 1 ) ; int k = 1 ; int flen = offset + len ; for ( int i = offset ; i < flen ; i ++ ) { int j = b [ i ] & 0xFF ; buf . append ( Character . forDigit ( ( j > > > 4 ) , 16 ) ) ; buf . append ( Character . forDigit ( ( j & 0x0F ) , 16 ) ) ; k ++ ; if ( k % 16 == 0 ) { buf . append ( '\n' ) ; k = 1 ; } else buf . append ( ' ' ) ; } return buf . toString ( ) ; }
dumps the content of a byte buffer using hexadecimal form .
