is it possible to "simplify" this code (particularly the for loop) using the latest java features (streams, etc) ? I've read examples such as these but it seems to make the code harder to read.
In other words, if a checked exception is thrown inside the execution of the loop, I want it to be propagated to the method running the loop.
public void function() throws IOException {
List<String> lines = new BufferedReader(new InputStreamReader(System.in)).lines().collect(Collectors.toList());
for (String line : lines) {
System.out.println(compute(line));
}
}
public int compute(String path) throws IOException {
// perform some compute and may throw IOException
return 0;
}