FindBugs reports a bug:
Reliance on default encoding Found a call to a method which will perform a byte to String (or String to byte) conversion, a
When you are using a PrintWriter,
File file = new File(file_path); Writer w = new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_16.name()); PrintWriter pw = new PrintWriter(w); pw.println(content_to_write); pw.close();