public static void deleteDirectory(final File directory) throws IOException {
    if (directory == null || !directory.isDirectory() || !directory.exists()) {
      return;
    }

    Files.walkFileTree(
        directory.toPath(),
        new SimpleFileVisitor<Path>() {
          @Override
          public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
              throws IOException {
            Files.delete(file);
            return FileVisitResult.CONTINUE;
          }

          @Override
          public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
            Files.delete(dir);
            return FileVisitResult.CONTINUE;
          }
        });
  }
BinDiff-specific file name and filesystem utility methods.
java/ui/src/main/java/com/google/security/zynamics/bindiff/utils/BinDiffFileUtils.java