read

Function read 

Source
pub fn read(fname: &str) -> Result<String>
Expand description

Reads the content of a file and returns it in a single string.

It is similar to Python’s f.read(), where f is a file handler.

§Examples

let content: String = jabba_lib::jfs::read("Cargo.toml").unwrap();
Examples found in repository?
examples/fs.rs (line 8)
4fn main() {
5    let lines = jfs::readlines("Cargo.toml").unwrap();
6    println!("Number of lines in Cargo.toml: {}", lines.len());
7    println!("---");
8    let content = jfs::read("Cargo.toml").unwrap();
9    println!("Number of characters in Cargo.toml: {}", content.len());
10    println!("---");
11    let f = jfs::open("Cargo.toml").unwrap();
12    for line in f.lines() {
13        let line = line.unwrap();
14        println!("{}", line);
15    }
16}