Here you can find the source of list2ByteBuffer(List
public static ByteBuffer list2ByteBuffer(List<Float> list)
//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> list) { ByteBuffer ibb = ByteBuffer.allocateDirect(list.size() << 2); ibb.order(ByteOrder.nativeOrder()); FloatBuffer fbb = ibb.asFloatBuffer(); for (float f : list) { fbb.put(f);/*from w ww. j a va 2 s .c om*/ } ibb.position(0); return ibb; } }