#065 ByteBufferPool
<source 2> ByteBufferPool.java
public class ByteBufferPool {
private static final int MEMORY_BLOCKSIZE = 4096;
private static final int FILE_BLOCKSIZE = 10240;
private final ArrayList memoryQueue = new ArrayList();
private final ArrayList fileQueue = new ArrayList();
private boolean wait = false;
public ByteBufferPool(int memorySize, int fileSize, File file) throws IOException {
if (memorySize > 0)
initMemoryBuffer(memorySize);
if (fileSize > 0)
initFileBuffer(fileSize, file);
}
private void initMemoryBuffer(int size) {
int bufferCount = size / MEMORY_BLOCKSIZE;
size = bufferCount * MEMORY_BLOCKSIZE;
ByteBuffer directBuf = ByteBuffer.allocateDirect(size);
divideBuffer(directBuf, MEMORY_BLOCKSIZE, memoryQueue);
}
private void initFileBuffer(int s...