`
lushuaiyin
  • 浏览: 701344 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

java Rumtime 例子

 
阅读更多

package two;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class Rrrr{

public static void main(String[] args) {

Runtime rn = Runtime.getRuntime();
Process p = null;
try {
//cmd /c是调用cmd下的start命令,它相当于对一个文件双击
// p = rn.exec( "cmd /k dir ");
//p = rn.exec("cmd /C Start D:\\ss.txt");
//p = rn.exec("cmd /C Start D:\\e");
p = rn.exec("cmd /C Start D:\\SQLyogEE-v7.14H\\SQLyogEnt.exe");
int status=p.waitFor();
if (status == 0)
{System.out.println("执行完毕");}
else
{System.out.println("执行失败");}


//InputStream in = p.getInputStream();
//BufferedReader br = new BufferedReader(new InputStreamReader(in));
//String str = null;
//while ((str = br.readLine()) != null) {
//System.out.println(str);
//}
//br.close();
} catch (Exception e) {
System.out.println("Error exec notepad ");
}
}


}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics