Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.pionier.net.pl!news.dialog.net.pl!not-for-mail From: Arivald Newsgroups: comp.lang.java.programmer Subject: Re: unnecessary code in Oracle example? Date: Thu, 10 Oct 2013 06:42:02 +0200 Organization: Dialog Net Lines: 25 Message-ID: References: NNTP-Posting-Host: dynamic-78-8-4-227.ssp.dialog.net.pl Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.dialog.net.pl 1381380314 17643 78.8.4.227 (10 Oct 2013 04:45:14 GMT) X-Complaints-To: abuse@dialog.net.pl NNTP-Posting-Date: Thu, 10 Oct 2013 04:45:14 +0000 (UTC) User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.0 In-Reply-To: Xref: csiph.com comp.lang.java.programmer:26271 W dniu 2013-10-10 04:56, Jim Janney pisze: > markspace writes: > >> On 10/9/2013 1:21 PM, Jim Janney wrote: >>> Yes, in Java 7 you can have clean syntax and clean semantics. Looks >>> like a win all around. >>> >> >> For Java 5+, with varargs you could do (not compiled): [...] > > Mmm... you're complicating the code with extra assignments and tests, > just to avoid one layer of nesting. I like the version with two > try-finally blocks, partly because the lexical structure reflects what's > happening in the code: two independent cleanups. But the Java 7 version > is better. > I wonder how Java 7 version (try-with-resources) handle exceptions... For example, if all 3 streams throw exception from close(), will it guarantee to close all of them? And how to handle such exceptions? -- Arivald