public static void deleteDirectory(Path path) {
        try {
            if (Files.exists(path)) {
                try (Stream<Path> walk = Files.walk(path)) {
                    walk.sorted(Comparator.reverseOrder())
                            .map(Path::toFile)
                            .forEach(File::delete);
                }
            }
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    }
@Test
    public void deleteDirectory() throws IOException {
        final Path tempDirectory = Files.createTempDirectory("temp");
        final Path tempFile = Files.createTempFile(tempDirectory, "temp", "temp");
        FileUtils.deleteDirectory(tempDirectory);
        assertThat(Files.exists(tempDirectory)).isFalse();
        assertThat(Files.exists(tempFile)).isFalse();
    }