I want to replace first x bytes of a file with y bytes. That is x and y are NOT same length. I tried copying to new file. Its working, but slow for large files. I know for exact length of replacement RAndomAccessfile can be used. But i am not able to use it for my purpose.
Thanks a lot for the your help.
If x
and y
aren't the same, you have no choice but to write y
and then write the remainder of the file, even if all you're doing is shifting the rest of the file up by y - x
bytes.