-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSRCUtil.java
37 lines (28 loc) · 1.07 KB
/
SRCUtil.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
package javaToolkit.lib.utils;
import java.util.List;
public class SRCUtil {
public static void changePackage(String oriSRCPath, String dstSRCPath, String newPackName) {
List<String> srcStrList = FileUtil.readFileToLineList(oriSRCPath);
Boolean ifchanged = false;
String wrtStr = "";
for (int i = 0; i < srcStrList.size(); i++) {
String line = srcStrList.get(i);
if (line.trim().startsWith("package ") && !ifchanged) {
line = "package " + newPackName + ";";
ifchanged = true;
}
wrtStr += (line + "\n");
}
FileUtil.writeStringToFile(dstSRCPath, wrtStr);
}
public static void main(String[] args) {
/*
* test purpose
*/
String oriPathString = "/home/appevolve/Desktop/2019_ISSTA_AE_225/run/Update_Example_Analysis+API-Usage_Update/EPR-Data/RepositoryWriter.java";
String dstPathString = "/home/appevolve/Desktop/2019_ISSTA_AE_225/run/Update_Example_Analysis+API-Usage_Update/EPR-Data/RepositoryWriter_tmp.java";
String newPackString = "main";
changePackage(oriPathString, dstPathString, newPackString);
System.out.println("Finished!");
}
}