Here you can find the source of setupIntBuffer(IntBuffer preBuffer, int[] array)
public static Buffer setupIntBuffer(IntBuffer preBuffer, int[] array)
//package com.java2s; import java.nio.Buffer; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.IntBuffer; public class Main { public static Buffer setupIntBuffer(IntBuffer preBuffer, int[] array) { if (preBuffer == null || preBuffer.capacity() < array.length) { preBuffer = createIntBuffer(array.length * 2); } else {/* w w w . ja v a 2 s . c om*/ preBuffer.clear(); } preBuffer.clear(); preBuffer.put(array); preBuffer.position(0); return preBuffer; } public static IntBuffer createIntBuffer(int count) { ByteBuffer data = ByteBuffer.allocateDirect(count * 4); data.order(ByteOrder.nativeOrder()); IntBuffer p1 = data.asIntBuffer(); return p1; } }