Skip to content

Instantly share code, notes, and snippets.

@b4284
Created May 26, 2015 11:48
Show Gist options
  • Save b4284/7808616c40fd54acc9a9 to your computer and use it in GitHub Desktop.
Save b4284/7808616c40fd54acc9a9 to your computer and use it in GitHub Desktop.
use std::fs::File;
use std::io::Read;
use std::string::String;
pub fn file_io_test(p: &str) {
let mut m = File::open(p).unwrap();
let ref mut buf = [0; 256];
let n = m.read(buf).unwrap();
let c = String::from_utf8_lossy(buf);
let s = c.into_owned();
println!("{} bytes read, printing them below:", n);
println!("{}", s);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment