From: Ross Bamford Date: 2006-10-13T01:33:11+09:00 Subject: Re: IO.readint ? On Fri, 2006-10-13 at 00:35 +0900, Rolando Abarca wrote: > Hi all, > I'm parsing a binary file, and need to read an integer, Check out String#unpack: (dta = File.read('ints.bin')).unpack('I' * (dta.length / 4)) # => [1234, 2345, 3456] It has different type specifiers for endianness and so on. Also, if you gotta crawl through the file, you can tell IO#read how many bytes you want: File.open('ints.bin') { |f| puts f.read(4).unpack('I') until f.eof? } # 1234 # 2345 # 3456 # => nil -- Ross Bamford - rosco@roscopeco.REMOVE.co.uk