Here you can find the source of copyByteBuffer(ByteBuffer src)
Parameter | Description |
---|---|
src | existing buffer to make a copy |
public static ByteBuffer copyByteBuffer(ByteBuffer src)
//package com.java2s; /**// w w w . j a v a2s .c om * 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.nio.ByteBuffer; import java.nio.ByteOrder; public class Main { /** * Make a copy of an existing buffer (src) to a new buffer (dest) * @param src existing buffer to make a copy * @return the new buffer copied */ public static ByteBuffer copyByteBuffer(ByteBuffer src) { ByteBuffer dest = newByteBuffer(src.capacity()); src.rewind(); dest.put(src); return dest; } /** * Allocate a new direct buffer * @param nbElements size of the ByteBuffer in bytes. * @return new direct buffer that holds nbElements bytes. */ public static ByteBuffer newByteBuffer(int nbElements) { ByteBuffer buffer = ByteBuffer.allocateDirect(nbElements); buffer.order(ByteOrder.nativeOrder()); return buffer; } }