boolean (@NotNull File file) { final String baseName = file.getName(); File parentFile = file.getParentFile(); final File[] files = parentFile != null ? parentFile.listFiles(pathname -> pathname.getName().startsWith(baseName)) : null; boolean ok = true; if (files != null) { for (File f : files) { ok &= FileUtil.delete(f); } } return ok; }