码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2016-02-24 22:37:53      阅读:261      评论:0      收藏:0      [点我收藏+]

标签:

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

 

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

标签:

原文地址:http://www.cnblogs.com/attilax/p/5215253.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!