Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.norbert;
- import java.io.*;
- public class PythonCaller {
- public static void main(String[] args) throws IOException {
- // set up the command and parameter
- String pythonScriptPath = "C:/Python/helloPython.py";
- String[] cmd = new String[2];
- cmd[0] = "C:/Python27/python.exe";
- cmd[1] = pythonScriptPath;
- // create runtime to execute external command
- Runtime rt = Runtime.getRuntime();
- Process pr = rt.exec(cmd);
- // retrieve output from python script
- BufferedReader bfr = new BufferedReader(new InputStreamReader(pr.getInputStream()));
- String line = "";
- while((line = bfr.readLine()) != null) {
- // display each output line form python script
- System.out.println(line);
- }
- }
- }
- def Add(x):
- x = x + 1
- return x
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement