Here you can find the source of allocateByteBuffer(int capacity)
Parameter | Description |
---|---|
capacity | capacity of buffer |
public static ByteBuffer allocateByteBuffer(int capacity)
//package com.java2s; import java.nio.ByteBuffer; public class Main { /**/*from w ww. j a v a2 s.c o m*/ * Minimum buffer size to use a direct buffer. */ public static final int MIN_DIRECT_BUFFER_SIZE = 128; /** * Allocate a {@link ByteBuffer}. * * @param capacity capacity of buffer * @return new buffer with the given capacity */ public static ByteBuffer allocateByteBuffer(int capacity) { return capacity >= MIN_DIRECT_BUFFER_SIZE ? ByteBuffer.allocateDirect(capacity) : ByteBuffer.allocate(capacity); } }