Home > Mobile >  Write bytes to file at a specific offset
Write bytes to file at a specific offset

Time:11-01

Basically, i want to write bytes to file at a specific position. I can't seem to find any possible solutions :/

I tried using openWrite() IOSink, to be exact addStream(), but that still doesnt let me skip to the specific byte in the file.

CodePudding user response:

You want to use a RandomAccessFile, which you can obtain via File.open/openSync.

From there, you can use RandomAccessFile.setPosition/setPositionSync and then use one of the various methods to write bytes (e.g. writeFrom/writeFromSync).

  • Related