Here you can find the source of getStr(ByteBuffer buff)
public static String getStr(ByteBuffer buff)
//package com.java2s; //License from project: Open Source License import java.nio.*; public class Main { /**/*from w w w . j ava 2s . c o m*/ * read a String from a ByteBuffer * that was written w/the putStr method */ public static String getStr(ByteBuffer buff) { short len = buff.getShort(); if (len == 0) { return null; } else { byte[] b = new byte[len]; buff.get(b); return new String(b); } } }