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