static ByteBuffer getTemporaryDirectBuffer ( int size ) { BufferCache cache = bufferCache . get ( ) ; ByteBuffer buf = cache . get ( size ) ; if ( buf != null ) { return buf ; } else { // No suitable buffer in the cache so we need to allocate a new // one. To avoid the cache growing then we remove the first // buffer from the cache and free it. if ( ! cache . isEmpty ( ) ) { buf = cache . removeFirst ( ) ; free ( buf ) ; } return ByteBuffer . allocateDirect ( size ) ; } }
Returns a temporary buffer of at least the given size