Java examples for java.nio:ByteBuffer String
get String from ByteBuffer
//package com.java2s; import java.nio.ByteBuffer; public class Main { public static String getString(ByteBuffer buf) { char len = buf.getChar(); StringBuilder sb = new StringBuilder(len); for (int i = 0; i < len; i++) { sb.append(buf.getChar());// w w w . j av a2 s. c om } return sb.toString(); } }