Java temp files and automated deletion

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.


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.


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

链接地址: http://www.djcxy.com/p/43112.html

上一篇: 如何处理BL中的嵌套数据上下文?

下一篇: Java临时文件和自动删除