Here you can find the source of asFloatBuffer(float[] array)
public static FloatBuffer asFloatBuffer(float[] array)
//package com.java2s; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.FloatBuffer; public class Main { public static final int BYTES_PER_FLOAT = Float.SIZE / Byte.SIZE; public static FloatBuffer asFloatBuffer(float[] array) { ByteBuffer bbuf = ByteBuffer.allocateDirect(array.length * BYTES_PER_FLOAT);//from w ww .ja v a2 s. c o m bbuf.order(ByteOrder.nativeOrder()); FloatBuffer fbuf = bbuf.asFloatBuffer(); fbuf.put(array); fbuf.position(0); return fbuf; } }