static Lock appendToFile_lock = lock(); static void appendToFile(S path, S s) ctex { lock appendToFile_lock; // Let's just generally synchronize this to be safe. new File(path).getParentFile().mkdirs(); //print("[Logging to " + path + "]"); Writer writer = new BufferedWriter(new OutputStreamWriter( newFileOutputStream(path, true), "UTF-8")); writer.write(s); writer.close(); } static void appendToFile(File path, String s) { if (path != null) appendToFile(path.getPath(), s); }