How can I write a loop with an until condition using Java 8 streams?
void readValue(char[] buf, int len, int curIndex) {
for(; curIndex < len; curIndex++) {
if(buf[curIndex] == '|') {
break;
} else {
System.out.print(buf[curIndex]);
}
}
}
When I use filter, it filters all the '|' characters. I want to break out when I encounter the first one.
Arrays.stream(buf, curIndex, len)
.filter(n -> n != '|')
.forEach(k -> System.out.print(k));