This is the clearest means I've seen of appending lines to a file. (and creating the file if it doesn't already exist)
String message = "bla";
Files.write(
Paths.get(".queue"),
message.getBytes(),
StandardOpenOption.CREATE,
StandardOpenOption.APPEND);
However, I need to add (OS) locking around it. I've browsed through examples of FileLock, but can't find any canonical examples in the Oracle Java tutorials, and the APIs are pretty impenetrable to me.