Here you can find the source of putString(ByteBuffer buffer, String s)
String
in a ByteBuffer
object.Parameter | Description |
---|---|
buffer | a destination buffer for the String. |
s | a String to copy in the Buffer |
public static void putString(ByteBuffer buffer, String s)
//package com.java2s; /**//from w ww .j a v a 2 s . c o m * NativeFmodEx Project * * Want to use FMOD Ex API (www.fmod.org) in the Java language ? NativeFmodEx is made for you. * Copyright ? 2005-2010 J?r?me JOUVIE (Jouvieje) * * Created on 23 feb. 2005 * @version file v1.5.0 * @author J?r?me JOUVIE (Jouvieje) * @site http://jerome.jouvie.free.fr/ * @mail jerome.jouvie@gmail.com * * INTRODUCTION * FMOD Ex is a music and sound effects system, by Firelight Technologies Pty, Ltd. * More informations can be found at: * http://www.fmod.org/ * The aim of this project is to provide a java interface for this amazing sound API. * * * GNU LESSER GENERAL PUBLIC LICENSE * * This library 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 2.1 of the License, * or (at your option) any later version. * * This library 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 this library; if not, write to the * Free Software Foundation, Inc., * 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA */ import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; public class Main { /** * Relative put operation.<BR> * Write a <code>String</code> in a <code>ByteBuffer</code> object.<BR><BR> * In some case, you also need to put a NULL terminal character at the end of the string. For this use <code>putNullTerminalCharacter</code>. * @param buffer a destination buffer for the String. * @param s a String to copy in the Buffer * @see #putNullTerminal(ByteBuffer) */ public static void putString(ByteBuffer buffer, String s) { buffer.put(s.getBytes()); } /** * @param charset string encoding * @see #putString(ByteBuffer, String) * @see #putNullTerminal(ByteBuffer) */ public static void putString(ByteBuffer buffer, String s, String charset) { try { buffer.put(s.getBytes(charset)); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } } }