1个回答
展开全部
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 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算法
1 | conclusion = runPHP.execPHP(ALGORITHM_RESIDUES_URL,imageResiduesId); |
//php接收
1 | $id = $argv [1]; |
因为此方法是java开进程直接调用php,因此是以内存方式传参
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询