-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
47 lines (32 loc) · 1.15 KB
/
Main.java
File metadata and controls
47 lines (32 loc) · 1.15 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
package com.company;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Main {
public static void main(String[] args) throws IOException, InterruptedException {
File fileR = new File(args[0]);
File fileW = new File(args[1]);
BufferedReader reader = new BufferedReader(new FileReader(fileR));
List<String> strings = new ArrayList<>();
List<Thread> threads = new ArrayList<>();
while (reader.ready()) {
strings.add(reader.readLine());
}
ThreadGroup threadGroup = new ThreadGroup("myGroup");
for (int i = 0; i < strings.size(); i++) {
threads.add(new Thread(threadGroup,new MyThreads(strings.get(i), new FileVisitCounter(), fileW.getName()),String.valueOf(i+1)));
}
for (Thread t : threads) {
t.start();
}
while (threadGroup.activeCount() > 0) {
Thread.sleep(1);
}
new MyCSVWriter(fileW.getName()).writerToCSV();
}
}