Here you can find the source of writeString(String string, ByteBuffer bb)
public static void writeString(String string, ByteBuffer bb)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; public class Main { public static void writeString(String string, ByteBuffer bb) { bb.putShort((short) string.length()); bb.put(string.getBytes());//w w w . j a v a 2 s . c o m } }