Python 的 subprocess.Popen() 的 Java 等价物是什么? [英] What is the Java equivalent of Python's subprocess.Popen()?

查看:34
本文介绍了Python 的 subprocess.Popen() 的 Java 等价物是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

import subprocess
import os

prefix = os.path.expanduser("~/.bin/kb/")
p = subprocess.Popen([(prefix + "koreball"),(prefix + "/data"),'3'])

推荐答案

您可以尝试使用 Runtime.exec 方法.

Your can try with the Runtime.exec method.

Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec("myprocess");

该方法返回一个 Process 可用于:

The method returns a Process that can be used to:

  • 检索流程输出、输入和错误流
  • 检索进程输出代码
  • 终止进程
  • 等待流程执行结束

这篇关于Python 的 subprocess.Popen() 的 Java 等价物是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆