Java ByteBuffer Allocate allocateDirect(int capacity)

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

Description

Allocate ByteBuffer in flush mode.

License

Open Source License

Parameter

Parameter Description
capacity capacity of the allocated ByteBuffer

Return

Buffer

Declaration

public static ByteBuffer allocateDirect(int capacity) 

Method Source Code

//package com.java2s;
//  are made available under the terms of the Eclipse Public License v1.0

import java.nio.ByteBuffer;

public class Main {
    /** Allocate ByteBuffer in flush mode.
     * The position and limit will both be zero, indicating that the buffer is
     * empty and in flush mode./*from   w  w  w.j a va2 s.  c  om*/
     * @param capacity capacity of the allocated ByteBuffer
     * @return Buffer
     */
    public static ByteBuffer allocateDirect(int capacity) {
        ByteBuffer buf = ByteBuffer.allocateDirect(capacity);
        buf.limit(0);
        return buf;
    }
}

Related

  1. allocate(int length)
  2. allocate(int length, byte fillwith)
  3. allocate(int size)
  4. allocate(int size)
  5. allocateBuffer(int size, boolean isDirect)
  6. allocateDirectBuffer(int size)
  7. allocateDirectInt(int size)
  8. allocateDoubles(final int howmany, final int SIZE)
  9. allocateFloats(final int howmany, final int SIZE)