atitit.基於bat cli的外掛管理系統.doc
/AtiPlatf/src_atibrow/com/attilax/cmd/CmdX.java
pathx.isWebPathMode=true;
String bat=pathx.classPathParent()+"/other/del_indexs.bat";
bat=bat.replace("/", "\\");
String cmd=" cmd.exe /c \""+bat+"\"";
System.out.println(cmd);
String r=exe(cmd);
System.out.println("----echo:"+r);
System.out.println("--f");
作者:: 綽號:老哇的爪子 ( 全名::Attilax Akbar Al Rapanui 阿提拉克斯 阿克巴 阿爾 拉帕努伊 ) 漢字名:艾龍, EMAIL:1466519819@qq.com
轉載請註明來源: http://www.cnblogs.com/attilax/
public static String exe(String cmd) {
try {
String r = "";
// 執行 CMD 命令
Process process = Runtime.getRuntime().exec(cmd);
//System.out.println("--echo stdin info:");
r = echoCmdResult_asStr(process.getInputStream());
//System.out.println("--echo err info:");
r = r + "\r\n" + echoCmdResult_asStr(process.getErrorStream());
//System.out.println("cmd ext finish!");
return r;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
private static String echoCmdResult_asStr(InputStream cmdStream)
{
String r="";
BufferedReader reader = null;
// BufferedReader reader;
InputStreamReader inputStreamReader;
try {
inputStreamReader = new InputStreamReader(cmdStream,
"gbk");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
throw new RuntimeException(e);
}
reader = new BufferedReader(inputStreamReader);
String line = null;
try {
line = reader.readLine();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
while (line != null) {
//System.out.println(line);
r=r+"\r\n"+line;
try {
line = reader.readLine();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return r;
}
Cank
atitit.外掛體系設計總結o73.doc - attilax的專欄 - 部落格頻道 - CSDN.NET.htm
Atitit 外掛機制原理與設計微核心 c# java 的實現attilax總結 - attilax的專欄 - 部落格頻道 - CSDN.NET.htm