public static String hex(ByteBuffer bytes,int offset,int length){
  try {
    ByteArrayOutputStream baos=new ByteArrayOutputStream();
    PrintStream ps;
    ps=new PrintStream(baos,true,"UTF-8");
    print(bytes,ps,offset,length);
    return baos.toString("UTF-8");
  }
 catch (  UnsupportedEncodingException e) {
    throw new RuntimeException(e);
  }
}

public static String hex ( ByteBuffer bytes , int offset , int length ) { try { ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; PrintStream ps ; ps = new PrintStream ( baos , true , "UTF-8" ) ; print ( bytes , ps , offset , length ) ; return baos . toString ( "UTF-8" ) ; } catch ( UnsupportedEncodingException e ) { throw new RuntimeException ( e ) ; } }
convert a subsection of a byte buffer to a human readable string of nicely formatted hex numbers . output looks like : < p > 01 02 03 04 05 06 07 08 01 02 03 04 05 06 07 08 01 02 03 04 05 06 07 08 01 02 03 04 05 06 07 08 01 02 03 04 05 06 07 08 01 02 03 04 05 06 07 08 01 02 03 04 05 06 07 08 01 02 03 04 05 06 07 08
