如何打开二进制文件读取记录、结构化数据?
读取二进制整数:
file = File.new(filename,"r")
num = file.read(2).unpack("S") #read an unsigned short
puts num #value will be less than expected