-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
executable file
·60 lines (49 loc) · 1.93 KB
/
Copy pathMain.java
File metadata and controls
executable file
·60 lines (49 loc) · 1.93 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
49
50
51
52
53
54
55
56
57
58
59
60
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;
public class Main {
public static void main(String[] args) throws IOException {
Map<String, String> API2Index;
File api2index = new File("/Users/zhangmingrui/Desktop/RecRankJavaEmersion/APIIndexMap.txt");
File dotFile = new File("/Users/zhangmingrui/Desktop/RecRankJavaEmersion/dotFile");
File allPathFile = new File("/Users/zhangmingrui/Desktop/RecRankJavaEmersion/AllPath.txt");
File countPathFile = new File("/Users/zhangmingrui/Desktop/RecRankJavaEmersion/PathCount.txt");
System.out.println("Read API2Index...");
API2Index = ReadAPI2Index.getAPI2IndexMap(api2index);
System.out.println("Finish Read API2Index");
System.out.println("Write Path...");
FileWriter fW = null;
PrintWriter pW = null;
fW = getFileWriter(allPathFile);
pW = getPrintWriter(fW);
WritePathResult.ergodicDir(dotFile, pW, API2Index);
ClosePWFW(pW, fW);
System.out.println("Finish Write Path");
System.out.println("Read And Count PathResult...");
fW = getFileWriter(countPathFile);
pW = getPrintWriter(fW);
ReadAndCountPathResult.readAndCount(allPathFile, pW);
ClosePWFW(pW, fW);
System.out.println("Finish Read And Count PathResult");
}
private static FileWriter getFileWriter(File file) throws IOException {
if (file.exists()) {
file.delete();
}
if (!file.exists()) {
file.createNewFile();
}
return new FileWriter(file, true);
}
private static PrintWriter getPrintWriter(FileWriter fW) {
return new PrintWriter(fW);
}
private static void ClosePWFW(PrintWriter pW, FileWriter fW) throws IOException {
pW.flush();
fW.flush();
pW.close();
fW.close();
}
}