Ruby File.read vs. File.gets
file-io, ruby
Solution
One is for reading "lines", one is for reading n bytes.
While byte buffering might be faster, a lot of that may disappear into the OS which likely does buffering anyway. IMO it has more to do with the context of the read--do you want lines, or are you just shuffling chunks of data around?
That said, a performance test in your specific environment may be helpful when deciding.
Problem
If I want to append the contents of a src file into the end of a dest file in Ruby, is it better to use: ``` while line = src.gets do ``` or ``` while buffer = src.read( 1024 ) ``` I have seen both used and was wondering when should I use each method and why?