Package org.eobjects.analyzer.job.tasks

Examples of org.eobjects.analyzer.job.tasks.Task


            throw new InvalidHttpResponseException(url, response);
          }

          final HttpEntity responseEntity = response.getEntity();
          final long expectedSize = responseEntity.getContentLength();
          publish(new Task() {
            @Override
            public void execute() throws Exception {
              _downloadProgressWindow.setExpectedSize(file, expectedSize);
            }
          });

          inputStream = responseEntity.getContent();
          outputStream = new BufferedOutputStream(new FileOutputStream(file));

          long bytes = 0;
          for (int numBytes = inputStream.read(buffer); numBytes != -1; numBytes = inputStream.read(buffer)) {
            if (_cancelled) {
              break;
            }
            outputStream.write(buffer, 0, numBytes);
            bytes += numBytes;

            final long totalBytes = bytes;
            publish(new Task() {
              @Override
              public void execute() throws Exception {
                _downloadProgressWindow.setProgress(file, totalBytes);
              }
            });
          }

          if (!_cancelled) {
            publish(new Task() {
              @Override
              public void execute() throws Exception {
                _downloadProgressWindow.setFinished(file);
              }
            });
View Full Code Here

TOP

Related Classes of org.eobjects.analyzer.job.tasks.Task

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.