語言

Files.ReadString 方法

定義

多載

名稱 Description
ReadString(IPath)

將檔案中的所有內容讀取成字串,並使用 StandardCharsets#UTF_8 UTF-8Charset charset.

ReadString(IPath, Charset)

將檔案中的所有字元讀入字串,並使用指定的字元集從位元組解碼為字元。

ReadString(IPath)

將檔案中的所有內容讀取成字串,並使用 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

參數

path
IPath

檔案路徑

傳回

一個包含從檔案讀取內容的字串

屬性

備註

將檔案中的所有內容讀取成字串,並使用 StandardCharsets#UTF_8 UTF-8Charset charset. 此方法確保當所有內容都已讀取或拋出 I/O 錯誤或其他執行時異常時,檔案會被關閉。

此方法等同於: readString(path, StandardCharsets.UTF_8)

新增11。

的 java.nio.file.Files.readString(java.nio.file.Path)Java 檔。

此頁面的部分是根據 Android 開放原始碼專案所建立和共用的工作進行修改,並根據 Creative Commons 2.5 屬性授權中所述的詞彙使用。

適用於

ReadString(IPath, 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

參數

path
IPath

檔案路徑

cs
Charset

用於解碼的字元集

傳回

一個包含從檔案讀取內容的字串

屬性

備註

將檔案中的所有字元讀入字串,並使用指定的字元集從位元組解碼為字元。 此方法確保當所有內容都已讀取或拋出 I/O 錯誤或其他執行時異常時,檔案會被關閉。

此方法會讀取所有內容,包括中間和/或末尾的行分隔符。 所得字串會包含檔案中出現的行分隔符。

新增11。

的 java.nio.file.Files.readString(java.nio.file.Path, java.nio.charset.Charset)Java 檔。

此頁面的部分是根據 Android 開放原始碼專案所建立和共用的工作進行修改,並根據 Creative Commons 2.5 屬性授權中所述的詞彙使用。

適用於