I am currently trying to recursively delete a directory... Strangely enough the shortest piece of code I was able to find is the following construct, employing an ad-hoc
FileUtils.deleteDirectory from Apache Commons IO deletes a directory recursively.
FileUtils.deleteDirectory
Example:
Path pathToBeDeleted = TEMP_DIRECTORY.resolve(DIRECTORY_NAME); boolean result = FileUtils.deleteDirectory(pathToBeDeleted.toFile());
For more information see Delete a Directory Recursively in Java.