I have a problem with the stream of Java 8 foreach attempting to move on next item in loop. I cannot set the command like continue;
, only return;
w
You can use a simple if
statement instead of continue. So instead of the way you have your code, you can try:
try(Stream lines = Files.lines(path, StandardCharsets.ISO_8859_1)){
filteredLines = lines.filter(...).foreach(line -> {
...
if(!...) {
// Code you want to run
}
// Once the code runs, it will continue anyway
});
}
The predicate in the if statement will just be the opposite of the predicate in your if(pred) continue;
statement, so just use !
(logical not).