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
It depends on how you're going to write to the file, but the simplest way is to open a new FileOutputStream without specifying that you plan to append to the file (note: the base FileOuptutStream constructor will truncate the file, but if you want to make it clear that the file's being truncated, I recommend using the two-parameter variant).