Topic: execute dos command from java

  Print this page

1.execute dos command from java Copy to clipboard
Posted by: dorrenchen
Posted on: 2003-11-13 04:56

this article shows how to do it.

http://www.artima.com/legacy/answers/Jul2001/messages/18.html


{ the credit is not really related to this piece of information but mainly for dorren's contribution to our forum, in particular on 科技英语 board -- why }

2.Re:execute dos command from java [Re: dorrenchen] Copy to clipboard
Posted by: lcwling
Posted on: 2003-11-13 19:46

in fact,this can same below:

Runtime rt = Runtime.getRuntime();
try {
rt.exec("batch.bat");
}
catch (IOException ex) {
}

3.Re:execute dos command from java [Re: dorrenchen] Copy to clipboard
Posted by: mokuram
Posted on: 2003-11-14 22:28

用这种方式运行,和在C里的效果不一样。
在JAVA中,是并发的执行;
在C中,是顺序的执行

4.Re:execute dos command from java [Re: dorrenchen] Copy to clipboard
Posted by: Janas
Posted on: 2003-11-28 18:08

請問從 Java 中要如何接收 batch.bat 所產生的訊習?

5.Re:execute dos command from java [Re: Janas] Copy to clipboard
Posted by: safe
Posted on: 2003-11-30 02:22

Janas wrote:
請問從 Java 中要如何接收 batch.bat 所產生的訊習?

You can get the message by way of Process.getInputStream()

ex:

Process p = Runtime.getRuntime().exec("batch.bat");
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = "";
while ((line = br.readLine()) != null) {
System.out.println(line);
}


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923