public static UnsafeMappedBytes allocate(File file, FileChannel.MapMode mode, long size) {
    if (file == null)
      throw new NullPointerException("file cannot be null");
    if (mode == null)
      mode = MappedMemoryAllocator.DEFAULT_MAP_MODE;
    if (size > MappedMemory.MAX_SIZE)
      throw new IllegalArgumentException("size for MappedBytes cannot be greater than " + MappedMemory.MAX_SIZE);
    return new UnsafeMappedBytes(file, MappedMemory.allocate(file, mode, size));
  }
public static UnsafeMappedBytes allocate ( File file , FileChannel . MapMode mode , long size ) { if ( file == null ) throw new NullPointerException ( "file cannot be null" ) ; if ( mode == null ) mode = MappedMemoryAllocator . DEFAULT_MAP_MODE ; if ( size > MappedMemory . MAX_SIZE ) throw new IllegalArgumentException ( "size for MappedBytes cannot be greater than " + MappedMemory . MAX_SIZE ) ; return new UnsafeMappedBytes ( file , MappedMemory . allocate ( file , mode , size ) ) ; }
Allocates a mapped buffer.
<p>
Memory will be mapped by opening and expanding the given {@link java.io.File} to the desired {@code count} and mapping the
file contents into memory via {@link java.nio.channels.FileChannel#map(java.nio.channels.FileChannel.MapMode, long, long)}.

@param file The file to map into memory. If the file doesn't exist it will be automatically created.
@param mode The mode with which to map the file.
@param size The count of the buffer to allocate (in bytes).
@return The mapped buffer.
@throws NullPointerException If {@code file} is {@code null}
@throws IllegalArgumentException If {@code count} is greater than {@link MappedMemory#MAX_SIZE}

@see UnsafeMappedBytes#allocate(java.io.File, long)