View Problem

Read the contents of a file into a string

ExpandDiskEdit
ruby
file = File.new("Solution108.rb")
whole_file = file.read
ExpandDiskEdit
erlang
Text = readfile("Solution607.erl"),
ExpandDiskEdit
erlang
Text = readfile("Solution608.erl"),
DiskEdit
csharp .Net 2.0 or later
string contents = System.IO.File.ReadAllText("filename.txt");
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")
ExpandDiskEdit
fantom
contents := File(`file.text`).readAllStr

Submit a new solution for ruby, erlang, csharp, fsharp ...
There are 15 other solutions in additional languages (clojure, cpp, groovy, haskell ...)