Here you can find the source of toHexString(ByteBuffer bb)
public static String toHexString(ByteBuffer bb)
//package com.java2s; //License from project: LGPL import java.nio.ByteBuffer; public class Main { private static final String HEXES = "0123456789ABCDEF"; public static String toHexString(ByteBuffer bb) { ByteBuffer buffer = bb.duplicate(); StringBuilder hex = new StringBuilder(); while (buffer.hasRemaining()) { byte b = buffer.get(); hex.append(HEXES.charAt((b & 0xF0) >> 4)).append(HEXES.charAt((b & 0x0F))); }/* ww w . ja va2s .c om*/ return hex.toString(); } public static String toHexString(int[] raw) { StringBuilder hex = new StringBuilder(); for (int b : raw) { hex.append(HEXES.charAt((b & 0xF000) >> 12)).append(HEXES.charAt((b & 0x0F00) >> 8)) .append(HEXES.charAt((b & 0x00F0) >> 4)).append(HEXES.charAt((b & 0x000F))); } return hex.toString(); } }