Skip to content

Instantly share code, notes, and snippets.

@cnmoro
Created August 12, 2019 01:58
Show Gist options
  • Save cnmoro/85ab14b7b1edd257e7fd56dcbe6f1cc5 to your computer and use it in GitHub Desktop.
Save cnmoro/85ab14b7b1edd257e7fd56dcbe6f1cc5 to your computer and use it in GitHub Desktop.
Java create temporary io.File
String text = "This is a text to be written on the temporary file.";
File tempFile = File.createTempFile("tempFilePrefix", "tempFileSuffix", null);
FileOutputStream fos = new FileOutputStream(tempFile);
fos.write(text.getBytes());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment