Theo
Theo

Reputation: 157

Write byte at a certain position on a binary file

How can I write something in a binary file, at a certain position, without having to copy the entire file, delete it and rewrite it with one value changed ?

I've tried with FileOutputStream but I can only append or truncate the file.

Upvotes: 1

Views: 1103

Answers (1)

In Java you can use a Random access file. You can set the position of the marker. Allowing you to choose where the next read or write occurs.

Upvotes: 6

Related Questions