Re: methods that throws checked exceptions in a lambda block

2014-02-12 Thread Remi Forax
On 02/12/2014 05:36 PM, Henry Jen wrote: On 02/12/2014 07:05 AM, Wang Weijun wrote: 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 wor

Re: methods that throws checked exceptions in a lambda block

2014-02-12 Thread Alan Bateman
On 12/02/2014 16:36, Henry Jen wrote: I am not sure there is a "recommended" way. Depends on how you need to handle those exceptions, I'll put the lambda in a private function to take care those exception, and surpress them in a UncheckedIOException. Yes, I think it depends on whether he want

Re: methods that throws checked exceptions in a lambda block

2014-02-12 Thread Paul Sandoz
On Feb 12, 2014, at 4:05 PM, Wang Weijun wrote: > 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? > It depends... Some

Re: methods that throws checked exceptions in a lambda block

2014-02-12 Thread Henry Jen
On 02/12/2014 07:05 AM, Wang Weijun wrote: 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 lam

methods that throws checked exceptions in a lambda block

2014-02-12 Thread Wang Weijun
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?)