Learning Ruby

Reading a file Part I


content = ""

File.open("foo.txt") do |file|
  while line = file.gets
    content += line
  end
end

puts "Here are the contents of the file: " + content

 

 

January 13, 2010 at 11:04 am