Java调用Python脚本

try
{
//python /Users/zhengjun/project/PycharmProjects/apkNLSigne/src/apkNLS.py
Process p = Runtime.getRuntime().exec("/Library/anaconda/envs/apkSign/bin/python /Users/zhengjun/project/PycharmProjects/apkNLSigne/src/apkNLS.py -i /Users/zhengjun/project/PycharmProjects/apkNLSigne/src/app-release.apk -o /Users/zhengjun/project/PycharmProjects/apkNLSigne/src/appSign.apk");

/* 等待调用返回 */
p.waitFor();

String s = null;

BufferedReader stdInput = new BufferedReader(new
InputStreamReader(p.getInputStream()));

BufferedReader stdError = new BufferedReader(new
InputStreamReader(p.getErrorStream()));

// read the output from the command
System.out.println("Here is the standard output of the command:\n");
while ((s = stdInput.readLine()) != null) {
System.out.println(s);
}

// read any errors from the attempted command
System.out.println("Here is the standard error of the command (if any):\n");
while ((s = stdError.readLine()) != null) {
System.out.println(s);
}

/* 打印调用执行结果 */
System.out.println(p.exitValue());

} catch (Exception e)
{
System.out.println("exception happened - here's what I know: ");
e.printStackTrace();
//System.exit(-1);
}