Udostępnij za pośrednictwem


Files.ReadAllLines Method

Definition

Overloads

ReadAllLines(IPath, Charset)

Read all lines from a file.

ReadAllLines(IPath)

Read all lines from a file.

ReadAllLines(IPath, Charset)

Read all lines from a file.

[Android.Runtime.Register("readAllLines", "(Ljava/nio/file/Path;Ljava/nio/charset/Charset;)Ljava/util/List;", "", ApiSince=26)]
public static System.Collections.Generic.IList<string>? ReadAllLines (Java.Nio.FileNio.IPath? path, Java.Nio.Charset.Charset? cs);
[<Android.Runtime.Register("readAllLines", "(Ljava/nio/file/Path;Ljava/nio/charset/Charset;)Ljava/util/List;", "", ApiSince=26)>]
static member ReadAllLines : Java.Nio.FileNio.IPath * Java.Nio.Charset.Charset -> System.Collections.Generic.IList<string>

Parameters

path
IPath

the path to the file

cs
Charset

the charset to use for decoding

Returns

the lines from the file as a List; whether the List is modifiable or not is implementation dependent and therefore not specified

Attributes

Remarks

Read all lines from a file. This method ensures that the file is closed when all bytes have been read or an I/O error, or other runtime exception, is thrown. Bytes from the file are decoded into characters using the specified charset.

This method recognizes the following as line terminators: <ul> <li> &#92;u000D followed by &#92;u000A, CARRIAGE RETURN followed by LINE FEED </li> <li> &#92;u000A, LINE FEED </li> <li> &#92;u000D, CARRIAGE RETURN </li> </ul>

Additional Unicode line terminators may be recognized in future releases.

Note that this method is intended for simple cases where it is convenient to read all lines in a single operation. It is not intended for reading in large files.

Java documentation for java.nio.file.Files.readAllLines(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

ReadAllLines(IPath)

Read all lines from a file.

[Android.Runtime.Register("readAllLines", "(Ljava/nio/file/Path;)Ljava/util/List;", "", ApiSince=26)]
public static System.Collections.Generic.IList<string>? ReadAllLines (Java.Nio.FileNio.IPath? path);
[<Android.Runtime.Register("readAllLines", "(Ljava/nio/file/Path;)Ljava/util/List;", "", ApiSince=26)>]
static member ReadAllLines : Java.Nio.FileNio.IPath -> System.Collections.Generic.IList<string>

Parameters

path
IPath

the path to the file

Returns

the lines from the file as a List; whether the List is modifiable or not is implementation dependent and therefore not specified

Attributes

Remarks

Read all lines from a file. Bytes from the file are decoded into characters using the StandardCharsets#UTF_8 UTF-8Charset charset.

This method works as if invoking it were equivalent to evaluating the expression:

{@code
            Files.readAllLines(path, StandardCharsets.UTF_8)
            }

Added in 1.8.

Java documentation for java.nio.file.Files.readAllLines(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