我寫了一個代碼,通過java調用一個python腳本,我嘗試過使用這兩種方法運作時.exec()和process builder,但通過這兩種方式,我面臨着相同的問題。在
我的代碼是:Process pr=Runtime.getRuntime().exec("/usr/bin/python /home/abhijeet/delete.py");
pr.waitFor();
System.out.println("----- will read ouput now -----");
BufferedReader br1=new BufferedReader(new InputStreamReader(pr.getInputStream()));
String line;
System.out.println("reached pont 1");
while ((line=br1.readLine())!=null)
{
System.out.println("inside while");
System.out.println("line--"+line);
}
System.out.println("outside while");
我添加了許多sop來了解程式的流程,但我的sop都沒有被調用,可能的原因是公共服務部()保持等等,如果我删除了br1.readline()傳回null和“reached point 1”和“outside while”消息印刷的。哪個意味着我的腳本沒有被調用。有人能看出我做錯了什麼嗎?在
我的python scip代碼是一個互動式代碼,代碼:
^{pr2}$