You'll have to read the whole file into memory, make your changes, then rewrite it back out to the file, deleting the old one and recreating the new one. To be safe, recreate the file with a temporary name, then delete the old file, then rename the temp file.
Phaelax
Practically a Posting Shark
858 posts since Mar 2004
Reputation Points: 92
Solved Threads: 51
Or better, use RandomAccessFile and just write the data you want at the place you want it selectively.
Takes some getting used to as you're no longer dealing with Writers but Streams but well worth is.
Typical sequence:
- move the file pointer
- create a buffer of data to write to the file
- write the buffer
jwenting
duckman
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337