Here you can find the source of bufferToString(ByteBuffer buf)
public static String bufferToString(ByteBuffer buf)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; public class Main { public static String bufferToString(ByteBuffer buf) { // This should only be used on ByteBuffers we've created by // wrapping an array return new String(buf.array(), StandardCharsets.UTF_8); }/* w ww.j a v a 2 s . c o m*/ }