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

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -