private void transfer(InputStream sourceStream,OutputStream targetStream,IProgressMonitor monitor,int length) throws IOException {
  monitor.beginTask(null,length < 0 ? 100 : Math.max(1,length / 1024));
  String total=length < 0 ? null : String.format("%.1fK",length / 1024.0d);
  byte[] buffer=new byte[1024];
  int downloaded=0;
  int num;
  int worked=0, newWorked=0;
  while ((num=sourceStream.read(buffer)) > 0) {
    targetStream.write(buffer,0,num);
    downloaded+=num;
    String taskName=(total == null ? String.format("(%.1fK)",(downloaded / 1024.0)) : String.format("(%.1fK/%s)",(downloaded / 1024.0),total));
    monitor.subTask(Messages.TransferingData + " " + taskName);
    if (length < 0) {
      newWorked=Math.min(worked + 1,99);
    }
 else {
      newWorked=downloaded / 1024;
    }
    if (newWorked > worked) {
      monitor.worked(newWorked - worked);
      worked=newWorked;
    }
  }
}

private void transfer ( InputStream sourceStream , OutputStream targetStream , IProgressMonitor monitor , int length ) throws IOException { monitor . beginTask ( null , length < 0 ? 100 : Math . max ( 1 , length / 1024 ) ) ; String total = length < 0 ? null : String . format ( "%.1fK" , length / 1024.0d ) ; byte [ ] buffer = new byte [ 1024 ] ; int downloaded = 0 ; int num ; int worked = 0 , newWorked = 0 ; while ( ( num = sourceStream . read ( buffer ) ) > 0 ) { targetStream . write ( buffer , 0 , num ) ; downloaded += num ; String taskName = ( total == null ? String . format ( "(%.1fK)" , ( downloaded / 1024.0 ) ) : String . format ( "(%.1fK/%s)" , ( downloaded / 1024.0 ) , total ) ) ; monitor . subTask ( Messages . TransferingData + " " + taskName ) ; if ( length < 0 ) { newWorked = Math . min ( worked + 1 , 99 ) ; } else { newWorked = downloaded / 1024 ; } if ( newWorked > worked ) { monitor . worked ( newWorked - worked ) ; worked = newWorked ; } } }
transfers all content from the source input stream to the target output stream .
