this question has answer here:
- java 8: lambda-streams, filter method exception 12 answers
i have code below.
private static void readstreamwithjava8() { stream<string> lines = null; try { lines = files.lines(paths.get("b.txt"), standardcharsets.utf_8); lines.foreachordered(line -> process(line)); } catch (ioexception e) { e.printstacktrace(); } { if (lines != null) { lines.close(); } } } private static void process(string line) throws myexception { // process here throws myexception }
here process(string line)
method throws checked exception , im calling method within lambda. @ point need throw myexception
readstreamwithjava8()
method without throwing runtimeexception
.
how can java8?
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.