From: Matthew Margolis Date: 2004-08-02T00:05:39+09:00 Subject: Re: Get the content of a file Dirk Einecke wrote: > Hi. > > Andreas Schwarz wrote: > >> Dirk Einecke wrote: >> >>> Is there a shorter way to get the content of a file? >> >> >> File.read(filename) > > > That's not working and I can not find read() here: > http://www.rubycentral.com/ref/ref_c_file.html > > I'm using Ruby 1.6.7 > > greetings > Dirk Einecke > Look here http://www.rubycentral.com/ref/ref_c_io.html#read . You are dealing with an IO object (the file) so you can use the IO methods. You can do something like aFile = File.new("#{textfilename}", "r") contentsoffile = aFile.read -Matthew Margolis