private static void transferStreams(InputStream source,OutputStream destination){
  byte[] buffer=new byte[8096];
  try {
    while (true) {
      int bytesRead=-1;
      try {
        bytesRead=source.read(buffer);
      }
 catch (      IOException e) {
        return;
      }
      if (bytesRead == -1)       break;
      try {
        destination.write(buffer,0,bytesRead);
      }
 catch (      IOException e) {
        return;
      }
    }
  }
  finally {
    try {
      source.close();
    }
 catch (    IOException e) {
    }
 finally {
      try {
        destination.close();
      }
 catch (      IOException e) {
      }
    }
  }
}

private static void transferStreams ( InputStream source , OutputStream destination ) { byte [ ] buffer = new byte [ 8096 ] ; try { while ( true ) { int bytesRead = - 1 ; try { bytesRead = source . read ( buffer ) ; } catch ( IOException e ) { return ; } if ( bytesRead == - 1 ) break ; try { destination . write ( buffer , 0 , bytesRead ) ; } catch ( IOException e ) { return ; } } } finally { try { source . close ( ) ; } catch ( IOException e ) { } finally { try { destination . close ( ) ; } catch ( IOException e ) { } } } }
transfers all available bytes from the given input stream to the given output stream . regardless of failure , this method closes both streams .
