Although I\'ve seen a lot of answers for similar questions I can\'t make the following code work as I think it should:
File dataDir = new File(\"C:\\\\User\\\\us
DirectoryStream
only iterates through the directory you give it and matches entries in that directory. It does not look in any sub-directories.
You need to use one of the walkXXXX methods of Files
to look in all directories. For example:
try (Stream<Path> stream = Files.walk(dataDir.toPath())) {
stream.filter(pathMatcher::matches)
.forEach(path -> System.out.println(path.toString()));
}