Last active
May 22, 2016 17:52
-
-
Save krobelus/5bbfd5ad0a3de4cbdfd314e02741a0f0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Override | |
| public void completed(Integer result, FileNameSizePair file) { | |
| System.out.println("read from file " + result); | |
| if(result == -1) | |
| return; | |
| boolean done = total == file.getFileSize(); | |
| if (result != 0) { | |
| total += result; | |
| try { | |
| buffer.flip(); | |
| dChannel.write(buffer); | |
| buffer.clear(); | |
| aChannel.read(buffer, file, this); | |
| if (!done) { | |
| return; | |
| } | |
| } catch (IOException e) { | |
| e.printStackTrace(); | |
| } | |
| } | |
| if (done) { | |
| System.out.println(" done = " + file.getFileName()); | |
| allDone.countDown(); | |
| // try { | |
| // dChannel.close(); | |
| // aChannel.close(); | |
| // } catch (IOException e) { | |
| // } | |
| // sChannels.remove(aChannel); | |
| // if (sChannels.isEmpty()) { | |
| // allDone.countDown(); | |
| // } | |
| return; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment