Java - atomically delete a (non-empty) directory

concurrency, io, java

Solution

The OS (Windows, Unix) doesn't support this operation, but what you can do is rename the directory or even move it away and then delete it later.

Problem

In a Java application, is there a way to atomically (with regards to other running processes) delete a non-empty directory?

Original source