read_text
fn read_text(string path) -> Result<string, IoError> Import
Source: use io::file::{read_text}; src/io/file.hy Reads the whole file at path as UTF-8 text.
Needs --allow-read.
Parameters#
| Name | Type |
|---|---|
path | string |
Returns#
Result<string, IoError>
Errors#
IoError::NotFound when the file does not exist and IoError::InvalidInput
when it is not valid UTF-8.
Examples#
use io::file::{read_text};
use io::sync::{println};
fn main() {
let config = read_text("config.toml")?;
println(config)?;
}
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.write_text: Replaces the contents of the file atpathwithtext, creating it if needed, and returns the number of bytes written.append_bytes: Appendsbufto the file atpath, creating it if needed.append_text: Appendstextto the file atpath, creating it if needed.