Here you can find the source of parseToByteBuffer(int capacity, String value)
public static ByteBuffer parseToByteBuffer(int capacity, String value)
//package com.java2s; /*//from w ww. j a va2 s . c o m mod_MumbleLink - Positional Audio Communication for Minecraft with Mumble Copyright 2011-2013 zsawyer (http://sourceforge.net/users/zsawyer) This file is part of mod_MumbleLink (http://sourceforge.net/projects/modmumblelink/). mod_MumbleLink is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. mod_MumbleLink is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with mod_MumbleLink. If not, see <http://www.gnu.org/licenses/>. */ import java.nio.ByteBuffer; public class Main { public static ByteBuffer parseToByteBuffer(int capacity, String value) { ByteBuffer buffer = ByteBuffer.allocate(capacity); buffer.rewind(); buffer.put(value.getBytes()); buffer.rewind(); return buffer; } }