Files.WriteString 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.
Overloads
| Name | Description |
|---|---|
| WriteString(IPath, ICharSequence, IOpenOption[]) |
Write a CharSequence to a file. |
| WriteString(IPath, String, IOpenOption[]) |
Writes a string to a file with UTF-8 encoding. |
| WriteString(IPath, ICharSequence, Charset, IOpenOption[]) |
Write a CharSequence to a file. |
| WriteString(IPath, String, Charset, IOpenOption[]) |
Writes a string to a file with the specified character encoding. |
WriteString(IPath, ICharSequence, IOpenOption[])
Write a CharSequence to a file.
[Android.Runtime.Register("writeString", "(Ljava/nio/file/Path;Ljava/lang/CharSequence;[Ljava/nio/file/OpenOption;)Ljava/nio/file/Path;", "", ApiSince=36)]
public static Java.Nio.FileNio.IPath? WriteString(Java.Nio.FileNio.IPath? path, Java.Lang.ICharSequence? csq, params Java.Nio.FileNio.IOpenOption[]? options);
[<Android.Runtime.Register("writeString", "(Ljava/nio/file/Path;Ljava/lang/CharSequence;[Ljava/nio/file/OpenOption;)Ljava/nio/file/Path;", "", ApiSince=36)>]
static member WriteString : Java.Nio.FileNio.IPath * Java.Lang.ICharSequence * Java.Nio.FileNio.IOpenOption[] -> Java.Nio.FileNio.IPath
Parameters
- path
- IPath
the path to the file
- csq
- ICharSequence
the CharSequence to be written
- options
- IOpenOption[]
options specifying how the file is opened
Returns
the path
- Attributes
Remarks
Write a CharSequence to a file. Characters are encoded into bytes using the UTF-8 charset. This method is equivalent to: writeString(path, csq, StandardCharsets.UTF_8, options).
Java reference for java.nio.file.Files.writeString.
Applies to
WriteString(IPath, String, IOpenOption[])
Writes a string to a file with UTF-8 encoding.
public static Java.Nio.FileNio.IPath? WriteString(Java.Nio.FileNio.IPath? path, string? csq, params Java.Nio.FileNio.IOpenOption[]? options);
static member WriteString : Java.Nio.FileNio.IPath * string * Java.Nio.FileNio.IOpenOption[] -> Java.Nio.FileNio.IPath
Parameters
- path
- IPath
The path of the file to write.
- csq
- String
The string to encode and write to the file.
- options
- IOpenOption[]
The options that control file creation and opening.
Returns
The path supplied to this method.
Remarks
This is the managed string overload of Java's writeString(Path, CharSequence, OpenOption...) method. It uses UTF-8, not the platform's default encoding.
Line separators in the string are retained. The method does not add a line separator or other characters.
If no options are supplied, the method uses Create, TruncateExisting, and Write. It creates a missing file or clears an existing regular file before writing. To change this behavior, supply the required open options.
Java reference for java.nio.file.Files.writeString with UTF-8 encoding.
Applies to
WriteString(IPath, ICharSequence, Charset, IOpenOption[])
Write a CharSequence to a file.
[Android.Runtime.Register("writeString", "(Ljava/nio/file/Path;Ljava/lang/CharSequence;Ljava/nio/charset/Charset;[Ljava/nio/file/OpenOption;)Ljava/nio/file/Path;", "", ApiSince=36)]
public static Java.Nio.FileNio.IPath? WriteString(Java.Nio.FileNio.IPath? path, Java.Lang.ICharSequence? csq, Java.Nio.Charset.Charset? cs, params Java.Nio.FileNio.IOpenOption[]? options);
[<Android.Runtime.Register("writeString", "(Ljava/nio/file/Path;Ljava/lang/CharSequence;Ljava/nio/charset/Charset;[Ljava/nio/file/OpenOption;)Ljava/nio/file/Path;", "", ApiSince=36)>]
static member WriteString : Java.Nio.FileNio.IPath * Java.Lang.ICharSequence * Java.Nio.Charset.Charset * Java.Nio.FileNio.IOpenOption[] -> Java.Nio.FileNio.IPath
Parameters
- path
- IPath
the path to the file
- csq
- ICharSequence
the CharSequence to be written
- cs
- Charset
the charset to use for encoding
- options
- IOpenOption[]
options specifying how the file is opened
Returns
the path
- Attributes
Remarks
Write a CharSequence to a file. Characters are encoded into bytes using the specified charset. All characters are written as they are, including the line separators in the char sequence. No extra characters are added. The options parameter specifies how the file is created or opened. If no options are present then this method works as if the CREATE, TRUNCATE_EXISTING, and WRITE options are present. In other words, it opens the file for writing, creating the file if it doesn't exist, or initially truncating an existing regular-file to a size of 0.
Java reference for java.nio.file.Files.writeString.
Applies to
WriteString(IPath, String, Charset, IOpenOption[])
Writes a string to a file with the specified character encoding.
public static Java.Nio.FileNio.IPath? WriteString(Java.Nio.FileNio.IPath? path, string? csq, Java.Nio.Charset.Charset? cs, params Java.Nio.FileNio.IOpenOption[]? options);
static member WriteString : Java.Nio.FileNio.IPath * string * Java.Nio.Charset.Charset * Java.Nio.FileNio.IOpenOption[] -> Java.Nio.FileNio.IPath
Parameters
- path
- IPath
The path of the file to write.
- csq
- String
The string to encode and write to the file.
- cs
- Charset
The character encoding to use when converting the string to bytes.
- options
- IOpenOption[]
The options that control file creation and opening.
Returns
The path supplied to this method.
Remarks
This is the managed string overload of Java's writeString(Path, CharSequence, Charset, OpenOption...) method. It converts the string to bytes with cs.
Line separators in the string are retained. The method does not add a line separator or other characters.
If no options are supplied, the method uses Create, TruncateExisting, and Write. It creates a missing file or clears an existing regular file before writing. To change this behavior, supply the required open options.
Java reference for java.nio.file.Files.writeString with a specified character encoding.