105 lines
2.6 KiB
Java
105 lines
2.6 KiB
Java
package util;
|
|
|
|
import java.io.InputStream;
|
|
|
|
/**
|
|
* @author lvxinran
|
|
* @date 2019/12/8
|
|
* @discribe
|
|
*/
|
|
public class ProcessUtil {
|
|
public static void main(String[] args) throws Exception {
|
|
ProcessBuilder processBuilder = new ProcessBuilder("C:\\Users\\Administrator\\Desktop\\hotfix.bat");
|
|
Process process = processBuilder.start();
|
|
InputStream in = process.getInputStream();
|
|
StringBuilder sb = new StringBuilder();
|
|
byte[] re = new byte[1024];
|
|
while (in.read(re) != -1) {
|
|
sb.append(new String(re));
|
|
}
|
|
String s = sb.toString();
|
|
String[] split =s.split("\n");
|
|
sb = new StringBuilder();
|
|
sb.append("[");
|
|
for (String s1:split){
|
|
String[] split1 = s1.split("\\.")[0].split("/");
|
|
if (split1.length<2){
|
|
continue;
|
|
}
|
|
String className = split1[split1.length-1];
|
|
String fullName = s1.split("\\.")[0].replace("/",".").split("com.ljsd.")[1];
|
|
sb.append(new HotClass(className,"com.ljsd."+fullName).toString()).append(",").append("\n");
|
|
}
|
|
sb.deleteCharAt(sb.lastIndexOf(",")).append("]");
|
|
HotFix hotFix = new HotFix();
|
|
hotFix.setVersion("1001");
|
|
hotFix.setClasses(sb.toString());
|
|
System.out.println(hotFix.toString());
|
|
in.close();
|
|
if (process.isAlive()) {
|
|
process.waitFor();
|
|
}
|
|
}
|
|
}
|
|
class HotClass{
|
|
private String name;
|
|
private String fullName;
|
|
|
|
public HotClass(String name, String fullName) {
|
|
this.name = name;
|
|
this.fullName = fullName;
|
|
}
|
|
|
|
public String getName() {
|
|
return name;
|
|
}
|
|
|
|
public String getFullName() {
|
|
return fullName;
|
|
}
|
|
|
|
public void setName(String name) {
|
|
this.name = name;
|
|
}
|
|
|
|
public void setFullName(String fullName) {
|
|
this.fullName = fullName;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return "{" +
|
|
"\"name\":" +"\""+ name +".class\""+
|
|
",\"fullName\":" +"\""+ fullName +"\"" +
|
|
'}';
|
|
}
|
|
}
|
|
class HotFix{
|
|
private String version;
|
|
private String classes;
|
|
|
|
public String getVersion() {
|
|
return version;
|
|
}
|
|
|
|
public String getClasses() {
|
|
return classes;
|
|
}
|
|
|
|
public void setVersion(String version) {
|
|
this.version = version;
|
|
}
|
|
|
|
public void setClasses(String classes) {
|
|
this.classes = classes;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return "{" +"\n"+
|
|
"\"version\":" +"\""+ version + '\"' +",\n"+
|
|
"\"classes\":" +classes +"\n"+
|
|
'}';
|
|
}
|
|
}
|