Here you can find the source of toHex(ByteBuffer bb)
public static StringBuffer toHex(ByteBuffer bb)
//package com.java2s; //License from project: LGPL import java.nio.ByteBuffer; public class Main { public static StringBuffer toHex(ByteBuffer bb) { StringBuffer sb = new StringBuffer(); // bb = bb.duplicate(); for (int i = 0; i < bb.limit(); i++) { sb.append(Integer.toString((bb.get(i) & 0xff) + 0x100, 16).substring(1)); }//from w ww .ja va2 s. c om return sb; } }