如何使用参数在Java中执行命令?
Process p = Runtime.getRuntime().exec(new String[]{"php","/var/www/script.php -m 2"});
Run Code Online (Sandbox Code Playgroud)
不行吗?
String[] options = new String[]{"option1", "option2"};
Runtime.getRuntime().exec("command", options);
Run Code Online (Sandbox Code Playgroud)
它是否也有效,因为它没有指定"m"参数.
我有这个字符串,我在Windows XP的JVM中使用Runtime.exec().
String cmd = encoderFull + " " + "-i " + originalFull + " "+ "-bitrate" + " " + bitrateVBR[i] + " " + "-bvhq"+ " " + "-avi " + outputFull + " " + "2>&1" + " " + "1>"+ outputFile + ".txt";
不幸的是'2>&1 1> output.txt'不起作用.其余的都没问题.有没有办法使用命令,以便创建此文件?
再见,大卫