Read a file to String

    0

    1

    Giovanny Gongora

    Codiga's Rust Recipes

    Read a local fila, store to a String and print the content

    use std::fs;
    
    let data = fs::read_to_string("/home/filename").expect("Impossible to read file");
    println!("{}", data);
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.