Android ByteBuffer Create makeByteBuffer(byte[] arr)

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

Description

Make a direct NIO ByteBuffer from an array of floats

Parameter

Parameter Description
arr The array

Return

The newly created FloatBuffer

Declaration

public static ByteBuffer makeByteBuffer(byte[] arr) 

Method Source Code

//package com.java2s;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

public class Main {
    /**// ww w  . ja va 2s.  c  om
     * Make a direct NIO ByteBuffer from an array of floats
     * 
     * @param arr
     *            The array
     * @return The newly created FloatBuffer
     */
    public static ByteBuffer makeByteBuffer(byte[] arr) {
        ByteBuffer bb = ByteBuffer.allocateDirect(arr.length);
        bb.order(ByteOrder.nativeOrder());
        bb.put(arr);
        bb.position(0);
        return bb;
    }

    public static ByteBuffer makeByteBuffer(int size) {
        ByteBuffer bb = ByteBuffer.allocateDirect(size);
        bb.position(0);
        return bb;
    }
}

Related

  1. renewBuffer(ByteBuffer buf)
  2. allocateAudioBuffer(int size)
  3. makeByteBuffer(byte[] array)
  4. ConvToByteBuffer(byte buf[])
  5. ConvToByteBuffer(byte buf[])
  6. makeByteBuffer(byte[] arr)
  7. makeByteBuffer(byte[] arr)
  8. makeByteBuffer(byte[] arr, int length)
  9. makeByteBuffer(byte[] i_arr)