Forces any updates to this channel's file to be written to the storage device that contains it.
If this channel's file resides on a local storage device then when this method returns it is guaranteed that all changes made to the file since this channel was created, or since this method was last invoked, will have been written to that device. This is useful for ensuring that critical information is not lost in the event of a system crash.
If the file does not reside on a local device then no such guarantee is made.
metaData parameter can be used to limit the number of
I/O operations that this method is required to perform. Passing
false for this parameter indicates that only updates to the
file's content need be written to storage; passing
indicates that updates to both the file's content and metadata must be
written, which generally requires at least one more I/O operation.
Whether this parameter actually has any effect is dependent upon the
underlying operating system and is therefore unspecified.
Invoking this method may cause an I/O operation to occur even if the channel was only opened for reading. Some operating systems, for example, maintain a last-access time as part of a file's metadata, and this time is updated whenever the file is read. Whether or not this is actually done is system-dependent and is therefore unspecified.
This method is only guaranteed to force changes that were made to
this channel's file via the methods defined in this class. It may or
may not force changes that were made by modifying the content of a
mapped byte buffer obtained by
map method. Invoking the
force method of the mapped byte buffer will
force changes made to the buffer's content to be written.
| If |
|If this channel is closed|
|If some other I/O error occurs|