diff options
| author | Jonathan Bauer | 2014-10-29 17:48:09 +0100 |
|---|---|---|
| committer | Jonathan Bauer | 2014-10-29 17:48:09 +0100 |
| commit | 37306c4ac39416662d8501949d263d0c45f0d062 (patch) | |
| tree | 01d7c82ca7b259d76b7c19ff2e6e0ff1ab09e272 | |
| parent | Merge branch 'master' of ssh://git.openslx.org/openslx-ng/tutor-module (diff) | |
| download | tutor-module-37306c4ac39416662d8501949d263d0c45f0d062.tar.gz tutor-module-37306c4ac39416662d8501949d263d0c45f0d062.tar.xz tutor-module-37306c4ac39416662d8501949d263d0c45f0d062.zip | |
[client] some comments for UploadTask
| -rw-r--r-- | dozentenmodul/src/main/java/ftp/UploadTask.java | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/dozentenmodul/src/main/java/ftp/UploadTask.java b/dozentenmodul/src/main/java/ftp/UploadTask.java index 68af1f3c..e0c6db29 100644 --- a/dozentenmodul/src/main/java/ftp/UploadTask.java +++ b/dozentenmodul/src/main/java/ftp/UploadTask.java @@ -60,11 +60,15 @@ public class UploadTask extends SwingWorker<Void, Void> { util.connect(); util.uploadFile(uploadFile, destDir); - FileInputStream inputStream = new FileInputStream(uploadFile); + // show filesize in the GUI long fileSize = uploadFile.length(); Image.image.setFilesize(fileSize); firePropertyChange("filesize", 0, fileSize); + // prepare input stream + FileInputStream inputStream = new FileInputStream(uploadFile); + + // initialize the counters needed for speed calculations percentCompleted = 0; byte[] buffer = new byte[BUFFER_SIZE]; int bytesRead = -1; @@ -88,11 +92,12 @@ public class UploadTask extends SwingWorker<Void, Void> { currentBytes = 0; } } + // finalize the upload by updating the progress bar one last time + // (in case we didn't get to do it because of the time interval) percentCompleted = (int) ((totalBytesRead * 100) / fileSize); setProgress(percentCompleted); firePropertyChange("bytesread", 0, totalBytesRead); inputStream.close(); - util.finish(); } catch (FTPException ex) { JOptionPane.showMessageDialog(null, |
