From: Mikael Brockman Date: 2004-08-02T02:27:22+09:00 Subject: Re: Get the content of a file Dirk Einecke writes: > Hi. > > Well - thanks to all. Now I've several ways: > > 1. > value = open(path) {|f| f.read} > > 2. > file = File.open(path, File::RDONLY) > value = file.read > file.close > > 3. > value = File.readlines(path).to_s > > 4. > value = File.readlines(path).join > > What is the fastes way (for Ruby) and what should I use? > > greetings > Dirk Einecke In my opinion, number one is the best. The latter two only make sense for line-based formats, and even in such cases it's easier to just read it all in at once. Number two, I assume, is just like number one, except you have to close it up yourself, which is annoying. mikael