Here you can find the source of setupFloatBuffer(FloatBuffer preBuffer, float[] array)
public static FloatBuffer setupFloatBuffer(FloatBuffer preBuffer, float[] array)
//package com.java2s; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.FloatBuffer; public class Main { public static FloatBuffer setupFloatBuffer(FloatBuffer preBuffer, float[] array) { if (preBuffer == null || preBuffer.capacity() < array.length) { preBuffer = createFloatBuffer(array.length * 2); } else {//w ww . j av a 2 s . com preBuffer.clear(); } preBuffer.put(array); preBuffer.position(0); return preBuffer; } public static FloatBuffer createFloatBuffer(int floatCount) { ByteBuffer data = ByteBuffer.allocateDirect(floatCount * 4); data.order(ByteOrder.nativeOrder()); FloatBuffer p1 = data.asFloatBuffer(); return p1; } }