-
Notifications
You must be signed in to change notification settings - Fork 0
/
compData.java
101 lines (84 loc) · 2.41 KB
/
compData.java
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class compData {
public static final String DIRPATH = "/Users/tatsuya/Documents/";
public static final String ACTUAL = "ActualGroups_";
public static final String TRUEGROUPS = "TrueGroups_";
public static final String TXT = ".txt";
public static void main(String args[]) {
Set<String> classSet = new HashSet<String>();
Set<String> compSet = new HashSet<String>();
Set<String> result = new HashSet<String>();
int count = 0;
//一つ目
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
try {
System.out.print("enter file name : ");
String line = reader.readLine();
if(line.equals("")) {
System.out.println("end. ");
return;
} else {
String path = DIRPATH + TRUEGROUPS + line +TXT;
System.out.println(line + "" + TXT);
readGroupData(path, classSet);
}
//二つ目
System.out.print("enter comp file name : ");
line = reader.readLine();
System.out.println(line);
if(line.equals("")) {
System.out.println("end. ");
return;
} else {
String path = DIRPATH + ACTUAL + line +TXT;
System.out.println(line + "" + TXT);
readGroupData(path, compSet);
}
//結果
System.out.println("output compare result");
Iterator<String> it = classSet.iterator();
while (it.hasNext()) {
String str = it.next();
if (compSet.contains(str)) {
count++;
System.out.println(str);
}
}
System.out.println(count);
} catch (IOException e) {
System.out.println(e);
}
}
public static void readGroupData(String path, Set<String> compSet) {
String tmp;
try {
FileReader filereader = new FileReader(path);
BufferedReader reader = new BufferedReader(filereader);
tmp = reader.readLine();
while( (tmp = reader.readLine() ) != null ) {
if ((tmp.length() == 0) || (tmp.contains("SimpleGroup") )) {
} else {
System.out.println(tmp);
compSet.add(tmp);
}
}
System.out.println(compSet.size());
reader.close();
} catch (FileNotFoundException e) {
System.out.println(e);
} catch (IOException e) {
System.out.println(e);
}
}
}