Navigation
Synopsis Read the contents of a file location and return it as a list of strings.
Function list[str] readFileLines(loc file) throws PathNotFound(loc file), IO(str msg)
Usage import IO;
Description Return the contents of a file location as a list of lines. Also see readFile.

Encoding

Look at readFile to understand how this function chooses the character set. If you know the character set used, please use readFileLinesEnc.
Pitfalls
  • In case encoding is not known, we try to estimate as best as we can (see readFile).
  • We default to UTF-8, if the file was not encoded in UTF-8 but the first characters were valid UTF-8, you might get an decoding error or just strange looking characters (see readFile).
Is this page unclear, or have you spotted an error? Please add a comment below and help us to improve it. For all other questions and remarks, visit ask.rascal-mpl.org.