Here you can find the source of readString(ByteBuffer byteBuffer)
public static String readString(ByteBuffer byteBuffer)
//package com.java2s; /*// www . ja va2 s. c o m * (C) 2007-2010 Alibaba Group Holding Limited. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * */ import java.nio.ByteBuffer; public class Main { public static String readString(ByteBuffer byteBuffer) { int len = byteBuffer.getInt(); if (len <= 1) { return ""; } else { byte[] b = new byte[len]; byteBuffer.get(b); return new String(b, 0, len - 1); } } }