Here you can find the source of allocateTestBuffer(int capacity, boolean direct)
private static ByteBuffer allocateTestBuffer(int capacity, boolean direct)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; public class Main { private static ByteBuffer allocateTestBuffer(int capacity, boolean direct) { ByteBuffer bb;/*w ww . j ava 2 s .c o m*/ if (direct) { bb = ByteBuffer.allocateDirect(capacity); } else { bb = ByteBuffer.allocate(capacity); } for (int i = 0; i < capacity; i++) { bb.put((byte) (i & 0xff)); } bb.flip(); return bb; } private static ByteBuffer allocateTestBuffer(int capacity) { return allocateTestBuffer(capacity, false); } }