Sdílet prostřednictvím


AtomicFile.StartWrite Method

Definition

Start a new write operation on the file.

[Android.Runtime.Register("startWrite", "()Ljava/io/FileOutputStream;", "GetStartWriteHandler")]
public virtual System.IO.Stream? StartWrite ();
[<Android.Runtime.Register("startWrite", "()Ljava/io/FileOutputStream;", "GetStartWriteHandler")>]
abstract member StartWrite : unit -> System.IO.Stream
override this.StartWrite : unit -> System.IO.Stream

Returns

Attributes

Exceptions

Remarks

Start a new write operation on the file. This returns a FileOutputStream to which you can write the new file data. The existing file is replaced with the new data. You <em>must not</em> directly close the given FileOutputStream; instead call either #finishWrite(FileOutputStream) or #failWrite(FileOutputStream).

Note that if another thread is currently performing a write, this will simply replace whatever that thread is writing with the new file being written by this thread, and when the other thread finishes the write the new write operation will no longer be safe (or will be lost). You must do your own threading protection for access to AtomicFile.

Java documentation for android.util.AtomicFile.startWrite().

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