File.read
$file.read($options={}) -> list|string
Description
Read the entire file and return a List of lines.
By default, it will skip over lines that are empty or have only whitespace characters.
$lines = file'files:/data.txt'.read() foreach $lines as $line { // ... }
NoteThis function reads the entire file into memory. For large files, use readEachLine instead.
Options
Option | Value | Description |
---|---|---|
keepBlanks |
true/false | Do not filter out blank lines. (list mode only) |
join |
true/false | Return the content as a single string, including blank lines and newline characters. |
$allLines = file'files:/data.txt'.read(-keepBlanks) $fullText = file'files:/data.txt'.read(-join)