I use the following idiom to read the whole file:
data = open(path) {|f| f.read}
Cheers,
Kent.
On Jul 25, 2004, at 4:56 AM, Dirk Einecke wrote:
> Hi.
>
> I've a method to read the content of a file.
>
> def readFile(path)
> value = ''
> file = File.open(path, File::RDONLY)
> while line = file.gets do
> value += line
> end
> file.close
> return value
> end
>
> I think the way line by line is not very efficiently.
> Is there a shorter way to get the content of a file?
>
> greetings
> Dirk Einecke
>