public static boolean deleteAllFilesStartingWith(@NotNull Path file) {
    String baseName = file.getFileName().toString();
    Path parentFile = file.getParent();
    if (parentFile == null) {
      return true;
    }

    List<Path> files = new ArrayList<>();
    try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(parentFile)) {
      for (Path path : directoryStream) {
        if (path.getFileName().toString().startsWith(baseName)) {
          files.add(path);
        }
      }
    }
    catch (NoSuchFileException ignore) {
      return true;
    }
    catch (IOException ignore) {
      return false;
    }

    boolean ok = true;
    for (Path f : files) {
      try {
        FileUtil.delete(f);
      }
      catch (IOException ignore) {
        ok = false;
      }
    }
    return ok;
  }
public static boolean deleteAllFilesStartingWith(@NotNull Path file)