public static void main(String[] args) throws IOException {
String s = null;
String command = "python <your_command>";
Process p = Runtime.getRuntime().exec(command);
BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
// 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);
}
}
1条答案
按热度按时间yacmzcpb1#
我不知道这是否对您有帮助,但您可以用这种方式在java中执行系统命令:
您可以在中看到一个详细的示例http://alvinalexander.com/java/edu/pj/pj010016
希望这对你有帮助