public void downloadToLocalFile(IProgressMonitor monitor, File file)
      throws InvocationTargetException {

    final int taskSize = 1024;

    monitor.setTaskName("Download file " + this.path);

    BufferedOutputStream ostream = null;
    DataInputStream istream = null;

    try {
      istream = getDFS().open(this.path);
      ostream = new BufferedOutputStream(new FileOutputStream(file));

      int bytes;
      byte[] buffer = new byte[taskSize];

      while ((bytes = istream.read(buffer)) >= 0) {
        if (monitor.isCanceled())
          return;
        ostream.write(buffer, 0, bytes);
        monitor.worked(1);
      }

    } catch (Exception e) {
      throw new InvocationTargetException(e);

    } finally {
      // Clean all opened resources
      if (istream != null) {
        try {
          istream.close();
        } catch (IOException e) {
          e.printStackTrace();
          // nothing we can do here
        }
      }
      try {
        ostream.close();
      } catch (IOException e) {
        e.printStackTrace();
        // nothing we can do here
      }
    }
  }
public void downloadToLocalFile ( IProgressMonitor monitor , File file ) throws InvocationTargetException { final int taskSize = 1024 ; monitor . setTaskName ( "Download file " + this . path ) ; BufferedOutputStream ostream = null ; DataInputStream istream = null ; try { istream = getDFS ( ) . open ( this . path ) ; ostream = new BufferedOutputStream ( new FileOutputStream ( file ) ) ; int bytes ; byte [ ] buffer = new byte [ taskSize ] ; while ( ( bytes = istream . read ( buffer ) ) >= 0 ) { if ( monitor . isCanceled ( ) ) return ; ostream . write ( buffer , 0 , bytes ) ; monitor . worked ( 1 ) ; } } catch ( Exception e ) { throw new InvocationTargetException ( e ) ; } finally { if ( istream != null ) { try { istream . close ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } try { ostream . close ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } }
Download the DfsFile to a local file. Use the given monitor to report
status of operation.

@param monitor the status monitor
@param file the local file where to put the downloaded file
@throws InvocationTargetException