Here you can find the source of createFloatBuffer(float[] array)
public static FloatBuffer createFloatBuffer(float[] array)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.FloatBuffer; import java.util.ArrayList; import java.util.HashMap; public class Main { private static HashMap<Integer, ArrayList<FloatBuffer>> floatBufferQueue; public static FloatBuffer createFloatBuffer(float[] array) { FloatBuffer result = genFloatBuffer(array.length << 2); result.put(array).flip();//from w w w .ja v a 2 s . c o m return result; } private static FloatBuffer genFloatBuffer(int size) { ArrayList<FloatBuffer> bufferList = floatBufferQueue.get(size); if (bufferList != null && bufferList.size() > 0) { FloatBuffer buffer = bufferList.remove(bufferList.size() - 1); return buffer; } return ByteBuffer.allocateDirect(size).order(ByteOrder.nativeOrder()).asFloatBuffer(); } }