【问题标题】:Why does not File.deleteOnExit work with directory?为什么 File.deleteOnExit 不适用于目录?
【发布时间】:2013-02-23 07:04:21
【问题描述】:

我是否以错误的方式使用deleteOnExit

我创建一个目录然后运行:

new File("my_dir_path").deleteOnExit();

尽管 JDK 文档说 Requests that the file or directory denoted by this abstract pathname be deleted when the virtual machine terminates.

【问题讨论】:

  • 那个 my_dir_path 是非空的吗?
  • 谢谢,我猜是这样。
  • 要有效地deleteOnExit 一个目录尝试shutdown hook

标签: java


【解决方案1】:

目录必须为空才能删除。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-04-09
    • 1970-01-01
    • 2011-04-17
    • 2022-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多