Home > Net >  Replace sequence of bytes in binary file Java
Replace sequence of bytes in binary file Java

Time:02-10

Is there a way in Java to replace a sequence of bytes in a binary file? I know there are the write methods in RandomAccessFile, but I'm looking for a way to replace the next N bytes in the file.

Edit: my understanding is that write will insert an array of bytes rather than replacing them.

For example:

Starting file: <byte0><byte1><byte2>...

What I want: <byte0><insertedByte><byte2>...

My understanding of how write works: <byte0><insertedByte><byte1><byte2>

CodePudding user response:

  •  Tags:  
  • Related