Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private class FileCountTask {
- private CompletionService<Integer> completionService;
- public FileCountTask(Executor threadpool) {
- completionService = new ExecutorCompletionService<Integer>(threadpool);
- }
- public int count(final SmbFile dir) throws Exception {
- return completionService.submit(new Callable<Integer>() {
- public Integer call() throws Exception {
- int res = 0;
- for (final SmbFile f : dir.listFiles()) {
- if (f.isDirectory()) res += count(f) + 1;
- else if (f.isFile()) res++;
- }
- return res;
- }
- }).get();
- }
- }
Add Comment
Please, Sign In to add comment