Android ByteBuffer Create makeByteBuffer(int size)

Here you can find the source of makeByteBuffer(int size)

Description

make Byte Buffer

License

Open Source License

Declaration

public static ByteBuffer makeByteBuffer(int size) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.nio.ByteBuffer;
import java.nio.ByteOrder;

public class Main {
    /**//from w  w  w . j av  a 2 s.  c o  m
     * 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. makeByteBuffer(byte[] arr)
  2. makeByteBuffer(byte[] arr, int length)
  3. makeByteBuffer(byte[] i_arr)
  4. makeByteBuffer(int size)
  5. makeByteBuffer(int size)
  6. copyFromStreamToBuffer(ByteBuffer out, DataInputStream in, int length)
  7. appendSurrogate(ByteBuffer bb, char c)