write_text
fn write_text(string path, string text) -> Result<int, IoError> Import
Source: use io::file::{write_text}; src/io/file.hy Replaces the contents of the file at path with text, creating it if needed, and returns the number of bytes written.
Needs --allow-write.
Parameters#
| Name | Type |
|---|---|
path | string |
text | string |
Returns#
Result<int, IoError>
Examples#
use io::file::{write_text, read_text};
fn main() {
write_text("greeting.txt", "hello\n")?;
let back = read_text("greeting.txt")?;
}
See also#
read_bytes: Reads the whole file atpath.write_bytes: Replaces the contents of the file atpathwithbuf, creating it if needed, and returns the number of bytes written.read_text: Reads the whole file atpathas UTF-8 text.append_bytes: Appendsbufto the file atpath, creating it if needed.append_text: Appendstextto the file atpath, creating it if needed.