Reputation:
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?
Upvotes: 3
Views: 227
Reputation: 12797
The trick you can use is :
delete()
operation. Upvotes: 0
Reputation: 12296
register custom shutdown hook with something like deleteDirectory from Commons IO
Upvotes: 4