Reputation: 2887
How do I write to a file from the beginning using RandomAccessFile? I am writing into a file in 3mb byte chunks until it hits 100mb for benchmarking.
Upvotes: 0
Views: 227
Reputation: 15622
How do I write to a file from the beginning using RandomAccessFile?
You have to move the content already written.
Imagine the hard disk as a Lego base plate. You can start at one edge to put blocks one after the other. The blocks are the chunks of data you want to write and any consecutive line of blocks is a "file".
However, if you want to put something at the beginning of the "file" you have to take of the blocks already there, put the new block at their position and put back the new locks behind them.
Upvotes: 1