Here you can find the source of list2FloatBuffer(List
public static FloatBuffer list2FloatBuffer(List<Float> arr)
//package com.java2s; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.FloatBuffer; import java.util.List; public class Main { public static FloatBuffer list2FloatBuffer(List<Float> arr) { ByteBuffer ibb = ByteBuffer.allocateDirect(arr.size() * 4); ibb.order(ByteOrder.nativeOrder()); FloatBuffer fbb = ibb.asFloatBuffer(); for (float f : arr) { fbb.put(f);// w w w.ja v a 2s . c o m } fbb.position(0); return fbb; } }