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
One liner using Files.write()...
Files.write(outFile, new byte[0], StandardOpenOption.TRUNCATE_EXISTING);
Can use File.toPath() to convert from File to Path prior as well.
Also allows other StandardOpenOptions.