FileChannel.Force(Boolean) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Forces any updates to this channel's file to be written to the storage device that contains it.
[Android.Runtime.Register("force", "(Z)V", "GetForce_ZHandler")]
public abstract void Force (bool metaData);
[<Android.Runtime.Register("force", "(Z)V", "GetForce_ZHandler")>]
abstract member Force : bool -> unit
Parameters
- metaData
- Boolean
If true
then this method is required to force changes
to both the file's content and metadata to be written to
storage; otherwise, it need only force content changes to be
written
- Attributes
Exceptions
if this channel is already closed.
if another I/O error occurs.
Remarks
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.
The 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 true
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 MappedByteBuffer <i>mapped byte buffer</i>
obtained by invoking the #map map
method. Invoking the MappedByteBuffer#force force
method of the mapped byte buffer will force changes made to the buffer's content to be written.
Java documentation for java.nio.channels.FileChannel.force(boolean)
.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.