boolean (String relativeName, List<Pattern> includes, List<Pattern> excludes) { boolean result = false; for (Pattern each : includes) { if (each.matcher(relativeName).matches()) { result = true; break; } } if (!result) return false; for (Pattern each : excludes) { if (each.matcher(relativeName).matches()) return false; } return true; }