Guest User

Untitled

a guest
Mar 17th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. private class FileCountTask {
  2. private CompletionService<Integer> completionService;
  3.  
  4. public FileCountTask(Executor threadpool) {
  5. completionService = new ExecutorCompletionService<Integer>(threadpool);
  6. }
  7.  
  8. public int count(final SmbFile dir) throws Exception {
  9. return completionService.submit(new Callable<Integer>() {
  10. public Integer call() throws Exception {
  11. int res = 0;
  12.  
  13. for (final SmbFile f : dir.listFiles()) {
  14. if (f.isDirectory()) res += count(f) + 1;
  15. else if (f.isFile()) res++;
  16. }
  17.  
  18. return res;
  19. }
  20. }).get();
  21. }
  22. }
Add Comment
Please, Sign In to add comment