From: Robert Klemme Date: 2008-02-28T17:55:06+09:00 Subject: Re: extracting hex keys from file 2008/2/28, Ben Aroia : > The java background is killing me here. ;) Thanks for pointing out the > IO#pos. IMHO something else is killing you: you did give only fractions of your problem description making it hard for people to come up with suggestions. Back to your problem: here's a more efficient solution than looping: def read_hex_io(io, offset, count) io.seek offset, File::SEEK_SET bytes = io.read count bytes.unpack("H*").shift end def read_hex(file, offset, count) File.open(file, "rb") do |io| read_hex_io io, offset, count end end Note: use the block form of File.open to ensure timely and safe closing of file descriptors. Cheers robert -- use.inject do |as, often| as.you_can - without end