Here you can find the source of allocateBuffer(int size, boolean isDirect)
public static ByteBuffer allocateBuffer(int size, boolean isDirect)
//package com.java2s; //License from project: Apache License import java.nio.ByteBuffer; public class Main { public static ByteBuffer allocateBuffer(int size, boolean isDirect) { final ByteBuffer buffer; if (isDirect) { buffer = ByteBuffer.allocateDirect(size); } else {//from w ww . j a v a 2 s .c om buffer = ByteBuffer.allocate(size); } return buffer; } }