filereader - Read each 8 bytes from a file in Ruby -
i'm trying read file in ruby, need read 8 bytes per time ex.:
file = "a1b2c3d4c5d6e7f8g9h0" file.each_8_bytes |f| puts f end output
=> a1b2c3d4 => c5d6e7f8 => g9h0 how it?
f = file.open(file) f.read(8) #=> a1b2c3d4 f.read(8) #=> c5d6e7f8 f.read(8) #=> g9h0 ... f.close or automatically,
file.open(file) |f| while s = f.read(8) puts s end end
Comments
Post a Comment