Added in API level 1

MappedByteBuffer

abstract class MappedByteBuffer : ByteBuffer
kotlin.Any
   ↳ java.nio.Buffer
   ↳ java.nio.ByteBuffer
   ↳ java.nio.MappedByteBuffer

A direct byte buffer whose content is a memory-mapped region of a file.

Mapped byte buffers are created via the FileChannel.map method. This class extends the ByteBuffer class with operations that are specific to memory-mapped file regions.

A mapped byte buffer and the file mapping that it represents remain valid until the buffer itself is garbage-collected.

The content of a mapped byte buffer can change at any time, for example if the content of the corresponding region of the mapped file is changed by this program or another. Whether or not such changes occur, and when they occur, is operating-system dependent and therefore unspecified.

All or part of a mapped byte buffer may become inaccessible at any time, for example if the mapped file is truncated. An attempt to access an inaccessible region of a mapped byte buffer will not change the buffer's content and will cause an unspecified exception to be thrown either at the time of the access or at some later time. It is therefore strongly recommended that appropriate precautions be taken to avoid the manipulation of a mapped file by this program, or by a concurrently running program, except to read or write the file's content.

Mapped byte buffers otherwise behave no differently than ordinary direct byte buffers.

Summary

Public methods
Buffer

Clears this buffer.

abstract ByteBuffer

Compacts this buffer  (optional operation).

abstract ByteBuffer

Creates a new byte buffer that shares this buffer's content.

Buffer

Flips this buffer.

MappedByteBuffer!

Forces any changes made to this buffer's content to be written to the storage device containing the mapped file.

MappedByteBuffer!
force(index: Int, length: Int)

Forces any changes made to a region of this buffer's content to be written to the storage device containing the mapped file.

Boolean

Tells whether or not this buffer's content is resident in physical memory.

Buffer
limit(newLimit: Int)

Sets this buffer's limit.

MappedByteBuffer!

Loads this buffer's content into physical memory.

Buffer

Sets this buffer's mark at its position.

Buffer
position(newPosition: Int)

Sets this buffer's position.

Buffer

Resets this buffer's position to the previously-marked position.

Buffer

Rewinds this buffer.

abstract ByteBuffer

Creates a new byte buffer whose content is a shared subsequence of this buffer's content.

abstract MappedByteBuffer
slice(index: Int, length: Int)

Creates a new byte buffer whose content is a shared subsequence of this buffer's content.

Inherited functions