OxL Reference

method File.writeText

Creates or truncates the file and writes text.

Example:

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

fn main() io {
  print("{File.exists("/definitely/not/here")}")
}
Output
false

Example:

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

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

Since. 1.0.0-beta

Parameters

NameType
pathstr
textstr

Returns

()

Errors

Effects

io

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

See also