Skip to content

Instantly share code, notes, and snippets.

@AndrewRussellHayes
Created October 20, 2015 12:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndrewRussellHayes/f1498cd73d8d26be9017 to your computer and use it in GitHub Desktop.
Save AndrewRussellHayes/f1498cd73d8d26be9017 to your computer and use it in GitHub Desktop.
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