Here you can find the source of readString(ByteBuffer buf)
public static String readString(ByteBuffer buf)
//package com.java2s; //License from project: LGPL import java.nio.ByteBuffer; public class Main { public static String readString(ByteBuffer buf) { StringBuilder bldr = new StringBuilder(); char c = (char) buf.get(); while (c != '\0') { bldr.append(c);/* ww w . j a v a 2 s .c om*/ c = (char) buf.get(); } return bldr.toString(); } }