Create a text file if it doesn't exist and append to it if it does using Java BufferedWriter

The answer is that you also need to specify open options when calling the newBufferedWriter method. What gets you is the default arguments as specified in the documentation:

If no options are present then this method works as if the CREATE, TRUNCATE_EXISTING, and WRITE options are present.

Specifically, it's TRUNCATE_EXISTING that causes the problem:

If the file already exists and it is opened for WRITE access, then its length is truncated to 0.

The solution, then, is to change

bwOfLog = Files.newBufferedWriter(pathOfLog, charSetOfLog);

to

bwOfLog = Files.newBufferedWriter(pathOfLog, charSetOfLog,StandardOpenOption.CREATE, StandardOpenOption.APPEND);

Probably obvious to long time Java coders, less so to new ones. Hopefully this will help someone avoid a bit of head banging.