public static void main(String[] args) throws IOException, InterruptedException {
String workDir = "E:/python_workspace/Python/machine_learning/forecasting";
String[] envp = new String[]{"WORKDIR=" + workDir};
Process exec = Runtime.getRuntime().exec("python ./run.py /c dir", envp, new File(workDir));
BufferedReader reader = new BufferedReader(new InputStreamReader(exec.getInputStream(),"GBK"));
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
//waitFor()方法目的是为了保证CMD命令执行完毕
int ec = exec.waitFor();
System.out.println("Process exited with code " + ec);
reader.close();
}