Here you can find the source of getUTF8FromByteBuffer(ByteBuffer bb)
public static String getUTF8FromByteBuffer(ByteBuffer bb)
//package com.java2s; //License from project: Open Source License import java.nio.*; import java.nio.charset.*; public class Main { public static String getUTF8FromByteBuffer(ByteBuffer bb) { Charset charset = Charset.forName("UTF-8"); CharsetDecoder decoder = charset.newDecoder(); try {//from w w w . j a v a 2 s . co m return decoder.decode(bb).toString(); } catch (Exception e) { e.printStackTrace(); } return null; } }