class Cfs {

    public static CompletableFuture<Integer> countLines(String...paths) {
        CompletableFuture[] cfs = Stream
            .of(paths) // Stream<String>
            .map(p ->  // Stream<Cf<Integer>>
                AsyncFiles.readAll(p).thenApply(body -> body.split("\n").length))         //Stream<Cf<Integer>>>
            .toArray(size -> new CompletableFuture[size]);

        return CompletableFuture
            .allOf(cfs)
            .thenApply(__ -> Stream
                .of(cfs)
                .mapToInt(cf -> (int) cf.join())
                .sum());
    }

}