Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.help > #751

Re: TeeOutputStream?

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From markspace <-@.>
Newsgroups comp.lang.java.help
Subject Re: TeeOutputStream?
Date Mon, 06 Jun 2011 14:08:03 -0700
Organization A noiseless patient Spider
Lines 24
Message-ID <isjfjk$muv$1@dont-email.me> (permalink)
References <YVzGp.501$_I7.309@newsfe08.iad>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Mon, 6 Jun 2011 21:08:05 +0000 (UTC)
Injection-Info mx04.eternal-september.org; posting-host="hpGRkhWunYQR6KaCc4QJ3w"; logging-data="23519"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+z844+fgf03BzeHYHiEB0W9HGYscTPoRc="
User-Agent Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10
In-Reply-To <YVzGp.501$_I7.309@newsfe08.iad>
Cancel-Lock sha1:CuzDjsjmuPTFg+cIbO//2ERohT0=
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.help:751

Show key headers only | View raw


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 | NextPrevious in thread | Next in thread | Find similar


Thread

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