API Reference › Fs › Fs.read_text
method

Fs.read_text

Fs.read_text(p) -> string

Reads an entire file into a string (UTF-8 text), or returns null when it cannot be opened — check for null rather than assuming success. For a missing or unreadable save, fall back to a fresh default.

Parameters

pthe path to read

Example

program ReadText {
  entry {
    if Fs.exists("saves/slot1.json") {
      let text = Fs.read_text("saves/slot1.json")
      print(len(text))
    }
  }
}
← All symbols