Skip to content

Instantly share code, notes, and snippets.

@jkutner
Created March 6, 2014 18:44
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 jkutner/9396632 to your computer and use it in GitHub Desktop.
Save jkutner/9396632 to your computer and use it in GitHub Desktop.
import java.io.File;
public class FileDemo {
public static void main(String[] args) {
File f = null;
try{
// creates temporary file
f = File.createTempFile("tmp-test", null);
// prints absolute path
System.out.print("File path: "+f.getAbsolutePath());
// deletes file when the virtual machine terminate
f.deleteOnExit();
}catch(Exception e){
// if any error occurs
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment