java中的exec命令
如果我在 java 中使用以下命令:
Process ps = Runtime.getRuntime().exec("some .exe file of VB");
我如何知道特定的 .exe 已完成其工作,例如:它执行成功。
我怎么知道它有一些错误或刚刚完成了java中的一半任务。 我应该如何用java设计我的程序才能知道或者有什么方法可以区分java和VB。
任何帮助表示赞赏。
If i am using following command in java:
Process ps = Runtime.getRuntime().exec("some .exe file of VB");
How do I know that the particular .exe has done its job eg: it executed successfully.
How do i know that it has some error or just completed half task in java.
How should I design my program in java to know or Is there any way to tell java from VB.
Any help is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我假设您可以查看程序的退出状态:
ps.exitValue()
或者您可以读取 stdout/stderrps.getInputStream()
/ps.getErrorStream()
分别。I would assume that you could look at the exit status of the program:
ps.exitValue()
or you could read the stdout/stderrps.getInputStream()
/ps.getErrorStream()
respectively.您将返回一个 Process
http://download.oracle.com/docs/cd/E17476_01/javase/1.4.2/docs/api/java/lang/Process.html
有这样的方法:
其中 需要
You get back a Process
http://download.oracle.com/docs/cd/E17476_01/javase/1.4.2/docs/api/java/lang/Process.html
Which has such methods as:
Which will get you what you need