Interface NIOService

    • Method Detail

      • allocate

        ByteBuffer allocate​(FileChannel channel,
                            FileChannel.MapMode mapMode,
                            long bufferStartPosition,
                            int newSize)
                     throws IOException
        Allocates or maps the desired file data into memory.

        This method provides a facade to byte buffer allocation that enables FileChannel.map() usage on platforms where it's unlikely to give us problems and heap allocation where it is.

        Parameters:
        channel - File channel to allocate or map byte buffers from.
        mapMode - The map mode. Required but only used if memory mapped I/O is to occur.
        bufferStartPosition - The absolute position of the start of the buffer.
        newSize - The buffer size.
        Returns:
        A newly allocated or mapped NIO byte buffer.
        Throws:
        IOException - If there is an issue mapping, aligning or allocating the buffer.
        See Also:
        "https://bugs.java.com/bugdatabase/view_bug.do?bug_id=5092131", "https://bugs.java.com/bugdatabase/view_bug.do?bug_id=6417205"