Java IntBuffer Create newDirectIntBuffer(final int theSize)

Here you can find the source of newDirectIntBuffer(final int theSize)

Description

new Direct Int Buffer

License

Open Source License

Declaration

public static IntBuffer newDirectIntBuffer(final int theSize) 

Method Source Code

//package com.java2s;
/*//from w w  w .  jav  a  2s .co  m
 * Copyright (c) 2013 christianr.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser Public License v3
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/lgpl-3.0.html
 * 
 * Contributors:
 *     christianr - initial API and implementation
 */

import java.nio.ByteBuffer;
import java.nio.ByteOrder;

import java.nio.IntBuffer;

public class Main {
    public static final int SIZE_OF_INT = 4;

    public static IntBuffer newDirectIntBuffer(final int theSize) {
        ByteBuffer myBuffer = ByteBuffer.allocateDirect(theSize * SIZE_OF_INT);
        myBuffer.order(ByteOrder.nativeOrder());
        return myBuffer.asIntBuffer();
    }
}

Related

  1. createIntBuffer(int size)
  2. createIntBuffer(int... data)
  3. createIntBuffer(int[] array)
  4. createIntBufferOnHeap(final int size)
  5. newDirectIntBuffer(final int theSize)