atitit.基于bat cli的插件管理系统.doc

来源:互联网 发布:淘宝帐号个人昵称大全 编辑:程序博客网 时间:2024/05/16 14:12

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://blog.csdn.net/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

 

0 0