Sprache

Files.ReadString Method

Definition

Overloads

Name Description
ReadString(IPath)

Reads all content from a file into a string, decoding from bytes to characters using the StandardCharsets#UTF_8 UTF-8Charset charset.

ReadString(IPath, Charset)

Reads all characters from a file into a string, decoding from bytes to characters using the specified Charset charset.

ReadString(IPath)

Reads all content from a file into a string, decoding from bytes to characters using the StandardCharsets#UTF_8 UTF-8Charset charset.

[Android.Runtime.Register("readString", "(Ljava/nio/file/Path;)Ljava/lang/String;", "", ApiSince=36)]
public static string? ReadString(Java.Nio.FileNio.IPath? path);
[<Android.Runtime.Register("readString", "(Ljava/nio/file/Path;)Ljava/lang/String;", "", ApiSince=36)>]
static member ReadString : Java.Nio.FileNio.IPath -> string

Parameters

path
IPath

the path to the file

Returns

a String containing the content read from the file

Attributes

Remarks

Reads all content from a file into a string, decoding from bytes to characters using the StandardCharsets#UTF_8 UTF-8Charset charset. The method ensures that the file is closed when all content have been read or an I/O error, or other runtime exception, is thrown.

This method is equivalent to: readString(path, StandardCharsets.UTF_8)

Added in 11.

Java documentation for java.nio.file.Files.readString(java.nio.file.Path).

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

ReadString(IPath, Charset)

Reads all characters from a file into a string, decoding from bytes to characters using the specified Charset charset.

[Android.Runtime.Register("readString", "(Ljava/nio/file/Path;Ljava/nio/charset/Charset;)Ljava/lang/String;", "", ApiSince=36)]
public static string? ReadString(Java.Nio.FileNio.IPath? path, Java.Nio.Charset.Charset? cs);
[<Android.Runtime.Register("readString", "(Ljava/nio/file/Path;Ljava/nio/charset/Charset;)Ljava/lang/String;", "", ApiSince=36)>]
static member ReadString : Java.Nio.FileNio.IPath * Java.Nio.Charset.Charset -> string

Parameters

path
IPath

the path to the file

cs
Charset

the charset to use for decoding

Returns

a String containing the content read from the file

Attributes

Remarks

Reads all characters from a file into a string, decoding from bytes to characters using the specified Charset charset. The method ensures that the file is closed when all content have been read or an I/O error, or other runtime exception, is thrown.

This method reads all content including the line separators in the middle and/or at the end. The resulting string will contain line separators as they appear in the file.

Added in 11.

Java documentation for java.nio.file.Files.readString(java.nio.file.Path, java.nio.charset.Charset).

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