Practice ยท 2 of 2
Walk, match, clean up
1. static List<String> findLogs(Path root) โ walk the tree depth 3, collect the
FILE NAMES (not full paths) of every regular file ending in .log, SORTED
alphabetically. Use try-with-resources on the stream.
2. static long totalBytes(Path root) โ sum file sizes of regular files at ANY
depth (Files.size; skip directories).
3. static boolean globMatches(String pattern, Path candidate) โ use
FileSystems.getDefault().getPathMatcher("glob:" + pattern) and
matcher.matches(candidate).
Difficulty: advanced
Press Submit to check your solution.
Back to lesson: Practice: File I/O drills