Java 临时文件和自动删除
使用java的createTempFile方法创建临时文件然后重命名并将其保留为永久文件是安全的吗?或者java或系统是否以某种方式跟踪的临时文件并在某个时候删除它们?
顺便说一句..这与 Mac OS X 特别相关。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
除非您调用 deleteOnExit()< /a> 文件对象上的方法,它将在应用程序终止后保留。
但是,最好在您的目录中创建文件,而不是在默认目录(通常为 /tmp)中创建文件,因为默认目录可能会被操作系统删除。
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.
看一下这篇关于 OSX 何时清理临时文件夹的文章:
http://www.xvsxp .com/system/system_tools_cleanup.php
我不会依赖临时文件夹作为存储文件的永久位置...
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...