static boolean deleteDir( Path dir )
    {
        try
        {
            if ( Files.isDirectory( dir ) )
            {
                Files.walkFileTree( dir, new SimpleFileVisitor<>()
                {
                    @Override
                    public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException
                    {
                        try {
                            Files.deleteIfExists(file);
                        } catch (IOException e) {
                            Log.debug("Plugin removal: could not delete: {}", file);
                            throw e;
                        }
                        return FileVisitResult.CONTINUE;
                    }

                    @Override
                    public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException
                    {
                        try {
                            Files.deleteIfExists(dir);
                        } catch (IOException e) {
                            Log.debug("Plugin removal: could not delete: {}", dir);
                            throw e;
                        }
                        return FileVisitResult.CONTINUE;
                    }
                } );
            }
            return Files.notExists( dir ) || Files.deleteIfExists( dir );
        }
        catch ( IOException e )
        {
            return Files.notExists( dir );
        }
    }
Deletes a directory.

@param dir the directory to delete.
@return true if the directory was deleted.
xmppserver/src/main/java/org/jivesoftware/openfire/container/PluginManager.java