(String[] args)
| 7 | |
| 8 | public class Find { |
| 9 | public static void |
| 10 | main(String[] args) throws Exception { |
| 11 | Path test = Paths.get("test"); |
| 12 | Directories.refreshTestDir(); |
| 13 | Directories.populateTestDir(); |
| 14 | // Creating a *directory*, not a file: |
| 15 | Files.createDirectory(test.resolve("dir.tmp")); |
| 16 | |
| 17 | PathMatcher matcher = FileSystems.getDefault() |
| 18 | .getPathMatcher("glob:**/*.{tmp,txt}"); |
| 19 | Files.walk(test) |
| 20 | .filter(matcher::matches) |
| 21 | .forEach(System.out::println); |
| 22 | System.out.println("***************"); |
| 23 | |
| 24 | PathMatcher matcher2 = FileSystems.getDefault() |
| 25 | .getPathMatcher("glob:*.tmp"); |
| 26 | Files.walk(test) |
| 27 | .map(Path::getFileName) |
| 28 | .filter(matcher2::matches) |
| 29 | .forEach(System.out::println); |
| 30 | System.out.println("***************"); |
| 31 | |
| 32 | Files.walk(test) // Only look for files |
| 33 | .filter(Files::isRegularFile) |
| 34 | .map(Path::getFileName) |
| 35 | .filter(matcher2::matches) |
| 36 | .forEach(System.out::println); |
| 37 | } |
| 38 | } |
| 39 | /* Output: |
| 40 | test\bag\foo\bar\baz\5208762845883213974.tmp |
nothing calls this directly
no test coverage detected