method File.writeText
Creates or truncates the file and writes text.
Example:
use std.io { File }
fn main() io {
print("{File.exists("/definitely/not/here")}")
}Вывод
false
Example:
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)!
}Вывод
two
pub(api) static fn writeText(path: str, text: str) -> () | IoError ioС версии. 1.0.0-beta
Параметры
| Имя | Тип |
|---|---|
path | str |
text | str |
Возвращает
()
Ошибки
IoError@error
Эффекты
io
Определено в: std/io/io.oxl:237