1 16 package org.apache.commons.vfs.util; 17 18 import java.io.BufferedOutputStream ; 19 import java.io.IOException ; 20 import java.io.OutputStream ; 21 22 27 public class MonitorOutputStream 28 extends BufferedOutputStream 29 { 30 private boolean finished; 31 32 public MonitorOutputStream(final OutputStream out) 33 { 34 super(out); 35 } 36 37 40 public void close() throws IOException 41 { 42 if (finished) 43 { 44 return; 45 } 46 47 IOException exc = null; 49 try 50 { 51 super.close(); 52 } 53 catch (final IOException ioe) 54 { 55 exc = ioe; 56 } 57 58 try 60 { 61 onClose(); 62 } 63 catch (final IOException ioe) 64 { 65 exc = ioe; 66 } 67 68 finished = true; 69 70 if (exc != null) 71 { 72 throw exc; 73 } 74 } 75 76 79 protected void onClose() throws IOException 80 { 81 } 82 } 83 | Popular Tags |