Answers for "read file in rust bufreader"

0

read file in rust bufreader

use std::fs::File;
use std::io::{self, prelude::*, BufReader};

fn main() -> io::Result<()> {
    let file = File::open("foo.txt")?;
    let reader = BufReader::new(file);

    for line in reader.lines() {
        println!("{}", line?);
    }

    Ok(())
}
Posted by: Guest on August-21-2021

Browse Popular Code Answers by Language