methods that throws checked exceptions in a lambda block

Wang Weijun at
Wed Feb 12 15:05:40 UTC 2014

This line does not compile

  Files.list(Paths.get("/secret")).forEach(x -> Files.write(x, new byte[Files.size(x)]);

because Files.write() and Files.size() throw IOE. Then what's the best way to make it work?

(I find some old threads on this on lambda-dev. Maybe we have a recommended way now?)


More information about the core-libs-dev mailing list