Here you can find the source of putString(ByteBuffer bb, String s)
public static void putString(ByteBuffer bb, String s)
//package com.java2s; //License from project: LGPL import java.nio.ByteBuffer; import java.nio.charset.Charset; public class Main { public static void putString(ByteBuffer bb, String s) { byte[] b = s.getBytes(Charset.forName("UTF-8")); bb.putShort((short) b.length); bb.put(b);// w ww .j a v a 2s. co m } }