Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
OutputStreamWriter is the preferred file write method as it does not make encoding assumptions
try (OutputStreamWriter osw =
new OutputStreamWriter(new FileOutputStream("/FilePath/Here"), "UTF-8")) {
PrintWriter pw = new PrintWriter(osw);
pw.write("Hello World");//does not add newline character
} catch (IOException e) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment