The following method represents a smart way of gathering subpaths within a path:
public static Path[] getDescendants(Path dir) {
try {
try (Stream<Path> entries = Files.walk(dir)) {
return entries.toArray(Path[]::new);
}
} catch (IOException ex) {
return new Path[0];
}
}
No comments:
Post a Comment