private static void tryDelete(Path path) throws IOException {
    IOException lastError = null;

    for (int i = 0; i < 10; i++) {
      try {
        Files.delete(path);
        LOG.info("deleted: " + path);
        return;
      }
      catch (NoSuchFileException e) {
        LOG.info("already deleted: " + path);
        return;
      }
      catch (AccessDeniedException e) {
        lastError = e;
        try {
          DosFileAttributeView view = Files.getFileAttributeView(path, DosFileAttributeView.class);
          if (view != null && view.readAttributes().isReadOnly()) {
            view.setReadOnly(false);
            continue;
          }
        }
        catch (IOException ignore) { }
      }
      catch (IOException e) {
        lastError = e;
      }

      pause(10);
    }

    throw new IOException("Cannot delete: " + path, lastError);
  }
private static void tryDelete(Path path)