Does Files.createTempDirectory remove the directory after JVM exits normally?

前端 未结 5 815
滥情空心
滥情空心 2020-12-15 04:06

Does Files.createTempDirectory remove the directory after JVM exits normally? Or do I need to manually recursively remove the temporary directory content?

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-15 04:46

    As per the API, no it doesn't, you need to manually remove the directory, using file.deleteOnExit() method.

    As with the createTempFile methods, this method is only part of a temporary-file facility. A shutdown-hook, or the File.deleteOnExit() mechanism may be used to delete the directory automatically.

提交回复
热议问题