有没有从Python调用Java的好方法
[java] view plain copy
String[] arg = new String[] {"python",types,parameter};//第一个参数是python解释器位置,第二个参数是执行的python脚本位置,接下来的都是参数
Process process = Runtime.getRuntime().exec(arg);
InputStreamReader inputStreamReader = new InputStreamReader(process.getInputStream());
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
String line = "";
StringBuffer stringBuffer = new StringBuffer();
while ((line = bufferedReader.readLine()) != null) {
stringBuffer.append(line);
stringBuffer.append("\n");
}
bufferedReader.close();
process.waitFor();
jpype 可以试试