Java examples for java.nio:FloatBuffer
array to Float Buffer
//package com.java2s; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.FloatBuffer; public class Main { public static void main(String[] argv) throws Exception { float[] coords = new float[] { 34.45f, 35.45f, 36.67f, 37.78f, 37.0000f, 37.1234f, 67.2344f, 68.34534f, 69.87700f }; System.out.println(arr2FloatBuffer(coords)); }/*from ww w. ja va 2 s . c o m*/ public static FloatBuffer arr2FloatBuffer(float[] coords) { ByteBuffer ibb = ByteBuffer.allocateDirect(coords.length * 4); ibb.order(ByteOrder.nativeOrder()); FloatBuffer fbb = ibb.asFloatBuffer(); fbb.put(coords); fbb.position(0); return fbb; } }