View Problem

Read the contents of a file into a string

DiskEdit
python
contents = open('myFile.txt', 'rt').read()
ExpandDiskEdit
erlang
Text = readfile("Solution607.erl"),
ExpandDiskEdit
erlang
Text = readfile("Solution608.erl"),
ExpandDiskEdit
fantom
contents := File(`file.text`).readAllStr
ExpandDiskEdit
fsharp
let file = new FileStream("test.txt", FileMode.Open)
let buffer = new String((new BinaryReader(file)).ReadChars(Convert.ToInt32(file.Length)))
ExpandDiskEdit
fsharp
let stream = new StreamReader("test.txt")
let buffer = stream.ReadToEnd()
ExpandDiskEdit
fsharp
let buffer = File.ReadAllText("test.txt")

Submit a new solution for python, erlang, fantom, or fsharp
There are 16 other solutions in additional languages (clojure, cpp, csharp, groovy ...)