I need to read a file in MB chunks, is there a cleaner way to do this in Ruby:
FILENAME=\"d:\\\\tmp\\\\file.bin\" MEGABYTE = 1024*1024 size = File.size(FILEN
You can use IO#each(sep, limit), and set sep to nil or empty string, for example:
IO#each(sep, limit)
sep
nil
chunk_size = 1024 File.open('/path/to/file.txt').each(nil, chunk_size) do |chunk| puts chunk end