I have following two variables;
final Path root; // /a/b/c final Stream<String> split; // 'd', 'e', 'f' Path path; // /a/b/c/d/e/f
I want to resolve every element in split
to the root
.
Currently I'm trying to do like this.
// is the final combiner ok? final Path path = split.reduce(root, (p, s) -> p.resolve(s), (p1, p2) -> p1);
Is this the right way? Is there any other way to do this?
Is following code better than the above code?
Path path = root; split.forEach(s -> path = path.resolve(s)); // path must be final?
Thanks.