Created
January 4, 2022 16:23
-
-
Save eduardonunesp/2536f11bdf84ecb0f5be9a2dec6b65c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let mut f = BufWrtier::new(File::create(filename).expect("Could not create file")); | |
let text = include_bytes!("filename.txt"); | |
f.write(text); | |
let text2 = include_str!("filename.txt"); | |
f.write(text2.as_bytes()); | |
let data = vec![b"this will be represented as a vector of bytes"]; | |
f.write(&data[..]); | |
use std::io::{BufReader, BufRead, BufWriter, Write}; | |
use std::fs::File; | |
use std::prelude::*; | |
// Buffered file reading | |
let mut f = BufReader::new(File::open("filename.txt").expect("Could not open file")); | |
for line in f.lines() { | |
match file_line { | |
Err(e) => println!("Error: {}", e); | |
Ok(line) => { | |
// ... | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment