Delete The First Bytes of a Random Access File in Java -


i'm writing bytes random access file. after completing operation, want delete first 100 bytes file. how can achieve this?

thanks in advance.

afaik, need copy remaining bytes (file length - 100) new file. deleting first 100 bytes file not possible without copying remaining bytes new file.

edit: cdhowie rightly pointed out, could:

  • seek 100,
  • read x amount of bytes (more 100 though)
  • seek 0,
  • write x amount of bytes

then repeat process until entire file written. finish off setting filelength 100 bytes less previously. if want on safe side , not risk corrupting original file, worth writing temp file first.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -