How does java purge existing content before each write without closing the stream?

scene description

If the

cycle processes some data and fails to process one, record the current offset to meta.txt , so that after the program exception stops, the last offset is read after the program is restarted next time, and the processing continues instead of starting all over again.

if you re-create FileOutputStream each time you want to write, you can empty the existing content, but with such a large number of new ones, close the stream. Personally, it feels like it consumes a lot of resources.

so is there any way to achieve my needs with very little expenditure?

in addition,
it occurred to me that before each write, delete the existing file and then create a new file, but still use the existing stream.
I don"t know if this is feasible?
if so, is it less expensive than each new stream?

Apr.05,2021

flush ()

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b32486-2bde7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b32486-2bde7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?