public static String toHexStream(ByteBuffer data){
  StringBuilder result=new StringBuilder();
  int counter=0;
  int b;
  while (data.hasRemaining()) {
    b=data.get() & 0xff;
    result.append(String.format("%02X ",b));
    counter++;
    if (counter % 16 == 0) {
      result.append("\n");
    }
  }
  return result.toString();
}

public static String toHexStream ( ByteBuffer data ) { StringBuilder result = new StringBuilder ( ) ; int counter = 0 ; int b ; while ( data . hasRemaining ( ) ) { b = data . get ( ) & 0xff ; result . append ( String . format ( "%02X " , b ) ) ; counter ++ ; if ( counter % 16 == 0 ) { result . append ( "\n" ) ; } } return result . toString ( ) ; }
convert data from given bytebuffer to hex
