tags:

views:

324

answers:

2

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.

A: 

Take a look at this article on when OSX cleansup the temporary file folders:

http://www.xvsxp.com/system/system_tools_cleanup.php

I wouldn't rely on the temporary file folder as a permanent place to store files...

Jon
+3  A: 

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.

David Rabinowitz
sorry one thing i forgot to mention, when i rename the temp file I am moving it to the users home directory.
leaf dev
In this case, it shouldn't be a problem.
David Rabinowitz