public static String dump(final ByteBuffer bytes){
  bytes.rewind();
  final int columns=16;
  final StringBuilder builder=new StringBuilder();
  int i=0;
  while (bytes.hasRemaining()) {
    if ((i % columns) != 0) {
      builder.append(' ');
    }
 else     if (i >= columns) {
      builder.append(String.format("%n"));
    }
    builder.append(String.format("%02x",bytes.get()));
    i++;
  }
  return builder.toString();
}

public static String dump ( final ByteBuffer bytes ) { bytes . rewind ( ) ; final int columns = 16 ; final StringBuilder builder = new StringBuilder ( ) ; int i = 0 ; while ( bytes . hasRemaining ( ) ) { if ( ( i % columns ) != 0 ) { builder . append ( ' ' ) ; } else if ( i >= columns ) { builder . append ( String . format ( "%n" ) ) ; } builder . append ( String . format ( "%02x" , bytes . get ( ) ) ) ; i ++ ; } return builder . toString ( ) ; }
dumps the specified byte buffer into a hex string and returns it .
