public static void recursiveDeleteDir(final @NonNull Path directory) {
        try {
            Files.walkFileTree(
                directory,
                new SimpleFileVisitor<Path>() {
                    @Override
                    public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
                        Files.delete(dir);
                        return FileVisitResult.CONTINUE;
                    }

                    @Override
                    public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                        Files.delete(file);
                        return FileVisitResult.CONTINUE;
                    }
                }
            );
        } catch (IOException ignored) {}
    }
Recursively delete a directory and all its subdirectories and files.

@param directory path to the directory to delete.
core/src/main/java/org/testcontainers/utility/PathUtils.java