JAVA传递带有空格的参数

 String s="b2 + b1";
Process child = Runtime.getRuntime().exec("C:\\eclipse-workspace\\beam\\exe\\bandmath\\BandMath.exe"+" \""+s+"\");

当java传递有空格的代码时s是有空格的参数 需要将" "+s+" "改为

+" \""+s+"\"这样才不会将s里面的空格参数识别为参数之间的空格
 public class cal {
public static void main(String[] args)
{
String s="B1 + B2";
String s1="B3+B4"; System.out.println(s1+" "+s);
System.out.println(s1+" \""+s+"\" ");
}
}

输出:

B3+B4 B1 + B2
B3+B4 "B1 + B2"

上一篇:Android开发第2篇 - Git插件安装


下一篇:<2013 12 28> AOI PCB设计