问题描述:

I need to read records from a file, each being 9 bytes long. I need to know how to start reading at different points in the file

网友答案:

It looks like you're looking for the seek function:

help?> seek
search: seek seekend seekstart ParseError setenv select select! selectperm

  seek(s, pos)

  Seek a stream to the given position.

In particular you might want to

open(filename) do f
    seek(f, n)  # seek past nth byte
    read(f, m)  # read m bytes
end

There is also the skip function that may come in useful

help?> skip
search: skip skipchars

  skip(s, offset)

  Seek a stream relative to the current position.
相关阅读:
Top