今天开发过程当中遇到一个问题,代码以下: String phantomjs_env = "D:\phantom js\phantomjs_env\"; String phantomjs_temp = "D:\phantom js\phantomjs_temp\"; String params = phantomjs_env +"phantomjs.exe "; params += phantomjs_env + "highcharts-convert.js " ; params += "-infile "+ option_file_path + " "; params += "-outfile " + out_image_path + "+ "-type png"; Runtime rt = Runtime.getRuntime(); Process p = rt.exec(params);
……省略部分代码开发
运行时报错,提示系统找不到制定路径get
猜想运行时将D:/phantom 看成了第一个参数io
修改代码以下 String params = """ + phantomjs_env +"phantomjs.exe"+ "" "; params += """ + phantomjs_env + "highcharts-convert.js" + "" "; params += "-infile " + """ + option_file_path + "" "; params += "-outfile " + """ + out_image_path + "" "+ "-type png"; 问题解决phantomjs
关键是将参数用双引号包起来file