Here you can find the source of readUTF8(ByteBuffer buf)
public static String readUTF8(ByteBuffer buf)
//package com.java2s; //License from project: Apache License import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; public class Main { public static String readUTF8(ByteBuffer buf) { short len = buf.getShort(); byte[] str = new byte[len]; buf.get(str);//from w w w .j a va 2 s . com String res = null; try { res = new String(str, "UTF-8"); } catch (UnsupportedEncodingException ex) { res = ""; } return res; } }