共用方式為


RandomAccessFile.WriteUTF(String) Method

Definition

Writes a string to the file using modified UTF-8 encoding in a machine-independent manner.

[Android.Runtime.Register("writeUTF", "(Ljava/lang/String;)V", "")]
public void WriteUTF (string? str);
[<Android.Runtime.Register("writeUTF", "(Ljava/lang/String;)V", "")>]
abstract member WriteUTF : string -> unit
override this.WriteUTF : string -> unit

Parameters

str
String

a string to be written.

Implements

Attributes

Exceptions

if an I/O error occurs while writing to this file.

if the encoded string is longer than 65535 bytes.

Remarks

Writes a string to the file using modified UTF-8 encoding in a machine-independent manner.

First, two bytes are written to the file, starting at the current file pointer, as if by the writeShort method giving the number of bytes to follow. This value is the number of bytes actually written out, not the length of the string. Following the length, each character of the string is output, in sequence, using the modified UTF-8 encoding for each character.

Java documentation for java.io.RandomAccessFile.writeUTF(java.lang.String).

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

See also