Android ByteBuffer Create arr2ByteBuffer(byte [] arr)

Here you can find the source of arr2ByteBuffer(byte [] arr)

Description

arr Byte Buffer

Declaration

public static ByteBuffer arr2ByteBuffer(byte [] arr)

Method Source Code

//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 << 2);
        ibb.order(ByteOrder.nativeOrder());
        FloatBuffer fbb = ibb.asFloatBuffer();
        fbb.put(arr);//  w w w.  jav a  2s .c  o m
        ibb.position(0);
        return ibb;
    }

    public static ByteBuffer arr2ByteBuffer(byte[] arr) {
        ByteBuffer ibb = ByteBuffer.allocateDirect(arr.length << 2);
        ibb.order(ByteOrder.nativeOrder());
        ibb.put(arr);
        ibb.position(0);
        return ibb;
    }
}

Related

  1. createByteBuffer(int count)
  2. createByteBuffer(int size)
  3. createByteBuffer(int size)
  4. createDirectByteBuffer( final int capacity, final ByteBuffer previous)
  5. createDirectByteBuffer(final int capacity)
  6. arr2ByteBuffer(byte[] arr)
  7. arr2ByteBuffer(float [] arr)
  8. arr2ByteBuffer(float[] arr)
  9. list2ByteBuffer(List arr)