I wrote this:
Arrays
.stream(docIDs.split(","))
.parallel()
.forEachOrdered(i -> {
try {
System.out.print(
Files.lines(Paths.get(spamDir +"\\cw12-" + i.substring(10,16) + ".txt"))
.filter(j -> j.matches("^(\\d\\d)\\s" + i))
.map(line -> line.substring(0, line.indexOf(" ")))
.findFirst()
.orElse("-1")
);
} catch (Exception e1) {
System.out.print("-1");
}
}
);
I am printing a part of string as you see above.
I need to put ',' comma between every element(number). { I am gonna check whether I am in last element and I am gonna put ',' commas according to that.This why I need to know if I am in last element. }
I thought so much but I couldn't find a way for solution.How can I do that?