- 论坛徽章:
- 0
|
求助:在java中用Runtime.getRuntime().exec(cmd)的问题
- private void sysCmd() {
- String syscmd = cmd.substring(1, cmd.length());
- String str = new String();
- syscmd = "cmd /c " + syscmd;
- //System.out.println(syscmd);
- try {
- Process p = Runtime.getRuntime().exec(syscmd);
- BufferedReader br = new BufferedReader(
- new InputStreamReader(p.getInputStream()));
- while ( (str = br.readLine()) != null) {
- System.out.println(str);
- }
- br.close();
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- }
复制代码
上面的代码是用来取cmd执行后的输出的
怎么停止,我也想知道.  |
|