Maps a region of this channel's file directly into memory.
A region of a file may be mapped into memory in one of three modes:
Read/write: Changes made to the resulting buffer will
eventually be propagated to the file; they may or may not be made
visible to other programs that have mapped the same file. (
Private: Changes made to the resulting buffer will not
be propagated to the file and will not be visible to other programs
that have mapped the same file; instead, they will cause private
copies of the modified portions of the buffer to be created. (
For a read-only mapping, this channel must have been opened for reading; for a read/write or private mapping, this channel must have been opened for both reading and writing.
mapped byte buffer
returned by this method will have a position of zero and a limit and
size; its mark will be undefined. The buffer and
the mapping that it represents will remain valid until the buffer itself
A mapping, once established, is not dependent upon the file channel that was used to create it. Closing the channel, in particular, has no effect upon the validity of the mapping.
Many of the details of memory-mapped files are inherently dependent upon the underlying operating system and are therefore unspecified. The behavior of this method when the requested region is not completely contained within this channel's file is unspecified. Whether changes made to the content or size of the underlying file, by this program or another, are propagated to the buffer is unspecified. The rate at which changes to the buffer are propagated to the file is unspecified.
For most operating systems, mapping a file into memory is more
expensive than reading or writing a few tens of kilobytes of data via
write methods. From the
standpoint of performance it is generally only worth mapping relatively
large files into memory.
| One of the constants |
|The position within the file at which the mapped region is to start; must be non-negative|
| The size of the region to be mapped; must be non-negative and
no greater than |
| If the |
| If the |
|If the preconditions on the parameters do not hold|
|If some other I/O error occurs|