Java ByteBuffer Allocate allocateNativeOrderDirectBuffer(int size)

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

Description

allocate Native Order Direct Buffer

License

Apache License

Declaration

public static ByteBuffer allocateNativeOrderDirectBuffer(int size) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

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

public class Main {
    public static ByteBuffer allocateNativeOrderDirectBuffer(int size) {
        ByteBuffer buf = allocateBuffer(size, true);
        buf.order(ByteOrder.nativeOrder());
        return buf;
    }/*from   w  ww . j  a  v  a 2 s . c om*/

    public static ByteBuffer allocateBuffer(int size, boolean isDirect) {
        final ByteBuffer buffer;
        if (isDirect) {
            buffer = ByteBuffer.allocateDirect(size);
        } else {
            buffer = ByteBuffer.allocate(size);
        }
        return buffer;
    }
}

Related

  1. allocateDirectInt(int size)
  2. allocateDoubles(final int howmany, final int SIZE)
  3. allocateFloats(final int howmany, final int SIZE)
  4. allocateInt()
  5. allocateInts(final int[] intarray, final int SIZE)
  6. allocateTestBuffer(int capacity, boolean direct)
  7. fromBytes(byte[] data, boolean[] preAllocatedValues)