read an arbitrary number of bytes from a file into a single variable using read: : read « File Directory « Ruby






read an arbitrary number of bytes from a file into a single variable using read:


File.open("text.txt") do |f|
  puts f.read(6)
end

 








Related examples in the same category

1.Reading the Contents of a File
2.Read 50 characters
3.Read file by chunk size