Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java temp files and automated deletion

Tags:

java

file

io

temp

It is safe to use java's createTempFile method to create a temp file and then rename it and keep it as a permanent file? Or does java or the system in some way keep track of its temporary files and delete them at some point?

btw..this is related to Mac OS X specifically.

like image 893
cweston Avatar asked Aug 30 '09 17:08

cweston


1 Answers

Unless you call the deleteOnExit() method on the file object, it will remain after the application terminates.

It is best however to create the file on your directory and not in the default directory (usually /tmp) which may be erased by the OS.

like image 194
David Rabinowitz Avatar answered Oct 20 '22 23:10

David Rabinowitz