Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #751
| From | markspace <-@.> |
|---|---|
| Newsgroups | comp.lang.java.help |
| Subject | Re: TeeOutputStream? |
| Date | 2011-06-06 14:08 -0700 |
| Organization | A noiseless patient Spider |
| Message-ID | <isjfjk$muv$1@dont-email.me> (permalink) |
| References | <YVzGp.501$_I7.309@newsfe08.iad> |
On 6/4/2011 5:17 PM, Knute Johnson wrote:
> public void close() throws IOException {
> try {
> os1.close();
> } finally {
> os2.close();
> }
> }
I've got into the habit of using a utility method like this (untested):
public void closeAll( Closeable... closeList ) {
for( Closeable c : closeList ) {
if( c != null ) {
try { c.close() }
catch( IOException ex ) {
// log...
}
}
}
Note that this also checks for null. Your close code conceivably could
also throw an NPE. I didn't show any exception chaining here, add it as
you like.
Back to comp.lang.java.help | Previous | Next — Previous in thread | Next in thread | Find similar
TeeOutputStream? Knute Johnson <nospam@knutejohnson.com> - 2011-06-04 17:17 -0700
Re: TeeOutputStream? Roedy Green <see_website@mindprod.com.invalid> - 2011-06-04 22:18 -0700
Re: TeeOutputStream? Stanimir Stamenkov <s7an10@netscape.net> - 2011-06-05 10:44 +0300
Re: TeeOutputStream? rossum <rossum48@coldmail.com> - 2011-06-05 12:23 +0100
Re: TeeOutputStream? Stanimir Stamenkov <s7an10@netscape.net> - 2011-06-06 01:23 +0300
Re: TeeOutputStream? Patricia Shanahan <pats@acm.org> - 2011-06-05 16:55 -0700
Re: TeeOutputStream? Stanimir Stamenkov <s7an10@netscape.net> - 2011-06-07 00:45 +0300
Re: TeeOutputStream? rossum <rossum48@coldmail.com> - 2011-06-06 15:16 +0100
Re: TeeOutputStream? markspace <-@.> - 2011-06-06 14:08 -0700
Re: TeeOutputStream? Henk van Voorthuijsen <voorth@gmail.com> - 2011-06-08 03:31 -0700
Re: TeeOutputStream? Knute Johnson <nospam@knutejohnson.com> - 2011-06-08 16:11 -0700
csiph-web