Create a gist now

Instantly share code, notes, and snippets.

Embed
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
pw.close();
} catch (IOException e) {
e.printstacktrace;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment