Here you can find the source of toByteBuffer(String value)
public static ByteBuffer toByteBuffer(String value) throws UnsupportedEncodingException
//package com.java2s; //License from project: Apache License import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; public class Main { public static ByteBuffer toByteBuffer(String value) throws UnsupportedEncodingException { return ByteBuffer.wrap(value.getBytes("utf-8")); }/*from w w w . jav a2s . co m*/ }