Here you can find the source of list2ByteBuffer(List
public static ByteBuffer list2ByteBuffer(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 ByteBuffer list2ByteBuffer(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);/*from w w w . j a v a2s . c om*/ } ibb.position(0); return ibb; } }