Here you can find the source of arr2ByteBuffer(byte[] arr)
public static ByteBuffer arr2ByteBuffer(byte[] arr)
//package com.java2s; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.FloatBuffer; public class Main { public static ByteBuffer arr2ByteBuffer(float[] arr) { ByteBuffer ibb = ByteBuffer.allocateDirect(arr.length * 4); ibb.order(ByteOrder.nativeOrder()); FloatBuffer fbb = ibb.asFloatBuffer(); fbb.put(arr);//w w w. j a v a2 s . co m ibb.position(0); return ibb; } public static ByteBuffer arr2ByteBuffer(byte[] arr) { ByteBuffer ibb = ByteBuffer.allocateDirect(arr.length); ibb.order(ByteOrder.nativeOrder()); ibb.put(arr); ibb.position(0); return ibb; } }