日期:2014-05-20 浏览次数:20826 次
Runtime runtime = Runtime.getRuntime();
String pingCommand = "tracert -m 10 www.qq.com"; //tracert读不出
//String pingCommand = "ping -c 5 www.qq.com"; //ping可以读出
Process pro = runtime.exec(pingCommand);
System.out.println(pingCommand);
InputStreamReader reader = new InputStreamReader(pro.getInputStream());
LineNumberReader input = new LineNumberReader (reader);
StringBuffer pingData = new StringBuffer();
String line = null;
while((line = input.readLine()) != null){
System.out.println("读出内容");
pingData.append(line+"<br>");
}