Java tutorial
//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 { 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; } }