Java ByteBuffer Create newByteBuffer(int nbElements)

Here you can find the source of newByteBuffer(int nbElements)

Description

Allocate a new direct buffer

License

LGPL

Parameter

Parameter Description
nbElements size of the ByteBuffer in bytes.

Return

new direct buffer that holds nbElements bytes.

Declaration

public static ByteBuffer newByteBuffer(int nbElements) 

Method Source Code

//package com.java2s;
/**//from w w  w . j a v a 2  s  . 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 {
    /**
     * 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;
    }
}

Related

  1. createIconsFromBuffers(List byteBuffers)
  2. createInputStream(final ByteBuffer buf)
  3. newByteArrayFromByteBuffer(ByteBuffer buf)
  4. newByteBuffer(int bufferSize, boolean direct)
  5. newByteBuffer(int len)
  6. newByteBuffer(int theSize)
  7. newDirectByteBuffer(int size)