What is the best-practice way to truncate a file in Java? For example this dummy function, just as an example to clarify the intent:
void readAndTruncate(Fil
new FileWriter(f) will truncate your file upon opening (to zero bytes), after that you can write lines to it
new FileWriter(f)