Java ByteBuffer Create createByteBuffer(int capacity)

Here you can find the source of createByteBuffer(int capacity)

Description

Allocates a direct native-ordered bytebuffer with the specified capacity.

License

Open Source License

Parameter

Parameter Description
capacity The capacity, in bytes

Return

a ByteBuffer

Declaration

public static ByteBuffer createByteBuffer(int capacity) 

Method Source Code


//package com.java2s;
/*/* w  ww . ja  va  2 s.  co m*/
 * Copyright LWJGL. All rights reserved.
 * License terms: http://lwjgl.org/license.php
 */

import java.nio.*;

public class Main {
    /**
     * Allocates a direct native-ordered bytebuffer with the specified capacity.
     *
     * @param capacity The capacity, in bytes
     *
     * @return a ByteBuffer
     */
    public static ByteBuffer createByteBuffer(int capacity) {
        return ByteBuffer.allocateDirect(capacity).order(ByteOrder.nativeOrder());
    }
}

Related

  1. createByteBuffer(byte... data)
  2. createByteBuffer(byte... values)
  3. createByteBuffer(byte[] data)
  4. createByteBuffer(int byteCount)
  5. createByteBuffer(int capacity)
  6. createByteBuffer(int size)
  7. createByteBuffer(int size)
  8. createByteBufferOnHeap(int size)
  9. createCopy(ByteBuffer buffer)