-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyThreads.java
More file actions
48 lines (37 loc) · 1.09 KB
/
MyThreads.java
File metadata and controls
48 lines (37 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package com.company;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
/**
* Created by senior on 18.06.15.
*/
public class MyThreads implements Runnable {
private String path;
private FileVisitCounter fileVisitor;
private String fileForWrite;
private long count;
public String getPath() {
return path;
}
public long getCount() {
return count;
}
public MyThreads(String path, FileVisitCounter fileVisitor, String fileForWrite) {
this.path = path;
this.fileVisitor = fileVisitor;
this.fileForWrite = fileForWrite;
}
@Override
public void run() {
Path p = new File(path).toPath();
try {
Files.walkFileTree(p, fileVisitor);
count = fileVisitor.getCount();
System.out.println(Thread.currentThread().getName() + "\t" + this.getCount() + "\t" + this.getPath());
new MyCSVWriter(fileForWrite).putResults(path,count);
} catch (IOException e) {
e.printStackTrace();
}
}
}