public static void copyWithClose ( InputStream input , OutputStream output ) throws IOException { try { copy ( input , output ) ; } finally { try { input . close ( ) ; } catch ( final IOException ignore ) { if ( log . isLoggable ( Level . FINER ) ) { log . finer ( "Could not close stream due to: " + ignore . getMessage ( ) + "; ignoring" ) ; } } try { output . close ( ) ; } catch ( final IOException ignore ) { if ( log . isLoggable ( Level . FINER ) ) { log . finer ( "Could not close stream due to: " + ignore . getMessage ( ) + "; ignoring" ) ; } } } }
Copies the contents from an InputStream to an OutputStream and closes both streams .