Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUST

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(())
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #read #file #rust #bufreader
ADD COMMENT
Topic
Name
1+1 =