我是否以错误的方式使用deleteOnExit
?
我创建了一个目录,然后运行:
new File("my_dir_path").deleteOnExit();
但是,在JVM终止且没有错误的情况下,该目录永远不会被删除,尽管JDK doc说Requests that the file or directory denoted by this abstract pathname be deleted when the virtual machine terminates.
答案 0 :(得分:4)
该目录必须为空才能将其删除。