commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bernd Eckenfels" <e...@zusammenkunft.net>
Subject Re: [imaging] Closing stream
Date Thu, 24 Oct 2013 02:34:41 GMT
Am 24.10.2013, 02:16 Uhr, schrieb Gary Gregory <garydgregory@gmail.com>:
>             try {
>                 if (outputStream != null) {
>                     outputStream.close();
>                 }
>             } catch (final Exception e) {
>                 Debug.debug(e);
>             }

this calls for a helper or a private method as soon as the code happens  
more than one time in a class IMHO.

> All of this is moot in Java 7 with try-with-resources blocks but we are  
> not
> ready for Java 7 here I imagine.

No, t-w-r is similiar broken to manually closing output streams in catch.  
both syntax constructs need a close (flush is optional) inside the try.  
Some filesystems and abstractions layers do nearly all work or error  
reporting in the close only (nfs, quota, webdav, ...)

Gruss
Bernd
-- 
http://www.zusammenkunft.net

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message