String[] cmd = new String[]{
"cmd.exe",
"/c",
// 第三个参数就是要打开的文冲碰件路径
"D:\埋判亮\Work\\workspace\\GIFRecorder.rar"弯宽
}
Runtime.getRuntime().exec(cmd)
想通过参数传递?public class as4 {
public static void main(String[] args){
int n = Integer.parseInt(args[0])
double factorial = 1
for (int i=1i<=ni++){
factorial = factorial*i
}
System.out.println("Factorial = " + factorial)
}
}
听说exec不能用于客斗渗户端?源春
这雹销耐个是真的。
public String execPHP(String scriptName, String param) {StringBuilder output = new StringBuilder()
BufferedReader input = null
String phpPath = "D:/xampp/php/php.exe"
try {
String line
带判答 Process p = Runtime.getRuntime().exec(phpPath + " " +scriptName + " " + param)
冲悉 input = new BufferedReader(new InputStreamReader(p.getInputStream()))
while ((line = input.readLine()) != null) {
output.append(line)
// p.destroy()//根据系统不同可能需要
}
p.destroy()
} catch (Exception err) {
err.printStackTrace()
}finally{
蠢慧 if(input != null){
try {
input.close()
} catch (IOException e) {
e.printStackTrace()
}
}
}
return output.toString()
}
//调用php算法
conclusion = runPHP.execPHP(ALGORITHM_RESIDUES_URL,imageResiduesId)//php接收
$id = $argv[1]因为此方法是java开进程直接调用php,因此是以内存方式传参
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)