From: Daniel Berger Date: 2006-03-23T06:04:19+09:00 Subject: Re: Best way to slurp a file into a string? Wes Gamble wrote: > All, > > I would like to capture the entire contents of a file in to a string (a > la Perl) - is this the best way to do it? > > File.open(@document.path, r) do |f| > @lines = f.readlines > html = @lines.join > end > > so that the html variable has all of the contents of f. > > Is there a better/easier way? > > Thanks, > Wes > IO.read(@document.path) Regards, Dan