OxL Reference

method File.readText

Whole file as UTF-8 text.

Example:

oxl✓ checked in CI
use std.io { File, fs }

fn main() io {
  let dir = fs.tempDir()!
  let p = "{dir}/a.txt"
  File.writeText(p, "hello")!
  print(File.readText(p)!)
  fs.removeAll(dir)!
}
Output
hello
pub(api) static fn readText(path: str) -> str | IoError  io

Since. 1.0.0-beta

Parameters

NameType
pathstr

Returns

str

Errors

Effects

io

Defined in: std/io/io.oxl:213

See also