Predicate<Path> () { return file -> { try { if (Files.isDirectory(file) || Files.isHidden(file)) { return false; } } catch (IOException e) { return false; } String fileName = file.getFileName().toString(); int index = fileName.lastIndexOf('.'); return index >= 0 && !fileName.endsWith(".txt") && !fileName.endsWith(".properties") && !fileName.regionMatches(index + 1, BACKUP_FILE_EXTENSION, 0, BACKUP_FILE_EXTENSION.length()); }; }