Java da Python Script Çağırmak Çalıştırmak

Java

public static  void main(String args[]) throws IOException {
  Runtime rt = Runtime.getRuntime();
  String[] commands = {"python",CallAnotherProgram.class.getClassLoader().getResource("script.py").getPath()};
  Process proc = rt.exec(commands);

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

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

  String s = null;
  while ((s = stdInput.readLine()) != null) {
      System.out.println(s);
  }


  while ((s = stdError.readLine()) != null) {
      System.out.println(s);
  }
}

 


Similar Posts:
  1. Java Annotations
  2. Java Covariant Return Type
  3. Java Enum

Tags: code, java, java code run python, java içinde python, java python, java python kod çalıştırmak, java python run, python