Here you can find the source of newDirectIntBuffer(final int theSize)
public static IntBuffer newDirectIntBuffer(final int theSize)
//package com.java2s; /*/*from ww w .ja v a2 s. 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(); } public static IntBuffer newDirectIntBuffer(final int[] theData) { ByteBuffer myBuffer = ByteBuffer.allocateDirect(theData.length * SIZE_OF_INT); myBuffer.order(ByteOrder.nativeOrder()); myBuffer.asIntBuffer().put(theData); myBuffer.rewind(); return myBuffer.asIntBuffer(); } }