Here you can find the source of bufferUTF(String string, ByteBuffer buffer)
public static void bufferUTF(String string, ByteBuffer buffer)
//package com.java2s; //License from project: Open Source License import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; public class Main { public static void bufferUTF(String string, ByteBuffer buffer) { try {/*ww w . j av a 2 s . co m*/ byte[] bytes = string.getBytes("UTF-8"); buffer.put(bytes); buffer.put((byte) 0); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } } }