From the PrintStream
docs:
fileName
- The name of the file to use as the destination of this print stream. If the file exists, then it will be truncated to zero size; otherwise, a new file will be created. The output will be written to the file and is buffered.
This code creates the file in my version of NetBeans. You could create the PrintStream
on the first error, instead of creating it no matter what.