Read file into a string Mar 6, 2016 This example shows how to read a file to a string. {:ok, contents} = File.read("exists.txt") {:error, reason} = File.read("doesnt_exist.txt") contents = File.read!("exists.txt") # Raises a File.Error contents = File.read!("doesnt_exist.txt")