Open a binary file with rb+ : Binary File « File Directory « Ruby






Open a binary file with rb+


f = open('binary', 'rb+')
f.read                                    
f.pos = 2
f.write('Hello.')
f.rewind
f.read                                    
f << 'Goodbye.'
f.rewind
f.read                                    

f.close

 








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.Seek by position
6.File read 500 bytes