只需将它们作为数组中的单独字符串提供,而不是将最后两个组合成
"val_31 val_32":
String[] command = {"script.py", "run", "-arg1", "val1", "-arg2", "val2" , "-arg3" , "val_31", "val_32", };
否则它将逃脱之间的空间
val_31,
val_32因为您告诉它它们是单个参数。顺便说一句,如果需要,也可以使用
varargs构造函数,而不必创建数组:
ProcessBuilder probuilder = new ProcessBuilder( "script.py", "run", "-arg1", "val1", "-arg2", "val2" , "-arg3" , "val_31", "val_32");
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)