Here you can find the source of toString(ByteBuffer buffer)
public static String toString(ByteBuffer buffer)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; public class Main { public static String toString(ByteBuffer buffer) { byte bytes[] = new byte[buffer.remaining()]; buffer.get(bytes);//from ww w . j av a 2s . c o m return new String(bytes); } }