7

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.

cweston
  • 11,297
  • 19
  • 82
  • 107

2 Answers2

4

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
  • 29,904
  • 14
  • 93
  • 125
0

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...

Jonathan Holloway
  • 62,090
  • 32
  • 125
  • 150