[Solved] Stream filter regex [closed]
You can use String’s startsWith method for this: List<File> fileListToProcess = Arrays.stream(allFolderPath) .filter(myFile -> myFile.getName().startsWith(“archive_”)) .collect(Collectors.toList()); OR You can use following regex to check if your string starts with archive_: ^(archive_).* like: List<File> fileListToProcess = Arrays.stream(allFolderPath) .filter(myFile -> myFile.getName().matches(“^(archive_).*”)) .collect(Collectors.toList()); solved Stream filter regex [closed]