Seek by position : Binary File « File Directory « Ruby






Seek by position


f = open('binary')
f.seek(8)
f.pos                                     

f.seek(-4, File::SEEK_CUR)
f.pos                                     
f.seek(2, File::SEEK_CUR)
f.pos                                     

# Move to the second-to-last byte of the file.
f.seek(-2, File::SEEK_END)
f.pos                                     

 








Related examples in the same category

1.Processing a Binary File
2.Read a binary file by byte
3.Read one byte from a binary file
4.Move file position
5.File read 500 bytes
6.Open a binary file with rb+