public static final String toSpacedHex(ByteBuffer bfr){
  bfr.mark();
  final StringBuilder sb=new StringBuilder();
  boolean firstTime=true;
  while (bfr.hasRemaining()) {
    final byte b=bfr.get();
    final int j=(b) & 0xFF;
    String bt=Integer.toHexString(j);
    if (bt.length() == 1) {
      bt="0" + bt;
    }
    if (firstTime) {
      firstTime=false;
    }
 else {
      sb.append(" ");
    }
    sb.append(bt);
  }
  bfr.reset();
  return sb.toString();
}

public static final String toSpacedHex ( ByteBuffer bfr ) { bfr . mark ( ) ; final StringBuilder sb = new StringBuilder ( ) ; boolean firstTime = true ; while ( bfr . hasRemaining ( ) ) { final byte b = bfr . get ( ) ; final int j = ( b ) & 0xFF ; String bt = Integer . toHexString ( j ) ; if ( bt . length ( ) == 1 ) { bt = "0" + bt ; } if ( firstTime ) { firstTime = false ; } else { sb . append ( " " ) ; } sb . append ( bt ) ; } bfr . reset ( ) ; return sb . toString ( ) ; }
converts a bytebuffer ' s contents to a spaced hex string with each byte represented as a two hex characters with each pair of characters except for the last pair separated from the following pair by a space character such as " 01 06 6e 65 6d 6f " . this particluar sequence happens to be the wire representation of a usernameattribute containing a name of " nemo " .
