private static final void transferStreams(InputStream source,OutputStream destination,String path,IProgressMonitor monitor) throws CoreException {
  monitor=Policy.monitorFor(monitor);
  try {
synchronized (buffer) {
      while (true) {
        int bytesRead=-1;
        try {
          bytesRead=source.read(buffer);
        }
 catch (        IOException e) {
          String msg=NLS.bind(Messages.failedReadDuringWrite,path);
          Policy.error(EFS.ERROR_READ,msg,e);
        }
        try {
          if (bytesRead == -1) {
            destination.close();
            break;
          }
          destination.write(buffer,0,bytesRead);
        }
 catch (        IOException e) {
          String msg=NLS.bind(Messages.couldNotWrite,path);
          Policy.error(EFS.ERROR_WRITE,msg,e);
        }
        monitor.worked(1);
      }
    }
  }
  finally {
    Policy.safeClose(source);
    Policy.safeClose(destination);
  }
}

private static final void transferStreams ( InputStream source , OutputStream destination , String path , IProgressMonitor monitor ) throws CoreException { monitor = Policy . monitorFor ( monitor ) ; try { synchronized ( buffer ) { while ( true ) { int bytesRead = - 1 ; try { bytesRead = source . read ( buffer ) ; } catch ( IOException e ) { String msg = NLS . bind ( Messages . failedReadDuringWrite , path ) ; Policy . error ( EFS . ERROR_READ , msg , e ) ; } try { if ( bytesRead == - 1 ) { destination . close ( ) ; break ; } destination . write ( buffer , 0 , bytesRead ) ; } catch ( IOException e ) { String msg = NLS . bind ( Messages . couldNotWrite , path ) ; Policy . error ( EFS . ERROR_WRITE , msg , e ) ; } monitor . worked ( 1 ) ; } } } finally { Policy . safeClose ( source ) ; Policy . safeClose ( destination ) ; } }
transfers the contents of an input stream to an output stream , using a large buffer .
