Skip to content

Instantly share code, notes, and snippets.

@krobelus
Last active May 22, 2016 17:52
Show Gist options
  • Select an option

  • Save krobelus/5bbfd5ad0a3de4cbdfd314e02741a0f0 to your computer and use it in GitHub Desktop.

Select an option

Save krobelus/5bbfd5ad0a3de4cbdfd314e02741a0f0 to your computer and use it in GitHub Desktop.
@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