JDK 7 introduces an API called Files.createTempDirectory
, but the directory created by the API is not automatically deleted when the JVM terminates.
And unfortunately File.deleteOnExit
does not work with a non-empty directory.
Is there a way to create a directory which is automatically deleted when JVM terminates?
register custom shutdown hook with something like deleteDirectory from Commons IO