/**
*获取文件并处理
*fileName-文件名
*这里的bat文件要与当前类,外于同一个包(文件夹)下面。
**/
private String getCmdText(String fileName) throws IOException{
String path=URLDecoder.decode(this.getClass().getResource(fileName).toString(),"UTF-8");
path=path.substring(6);
return "cmd /c start "+path.replaceAll("/", "//""); //处理存在空格的路径(关键)
}
//--------------------------------------------调用------------------------------------------------
/**
* 启动
*/
public String start(){
try{
Runtime.getRuntime().exec(getCmdText("start.bat"));
return "1";
}catch (Exception e) {
e.printStackTrace();
return "0" }
}