다음을 통해 공유


AsynchronousFileChannel.Force(Boolean) Method

Definition

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", ApiSince=26)]
public abstract void Force (bool metaData);
[<Android.Runtime.Register("force", "(Z)V", "GetForce_ZHandler", ApiSince=26)>]
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

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.

Java documentation for java.nio.channels.AsynchronousFileChannel.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.

Applies to