import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
/**
* 類說明
*
* @author nmj
* @email [email protected]
* @date 2017年5月17日 新建
*/
public class test {
public static void main(String[] args) {
// start
try {
Process pro = Runtime.getRuntime().exec("ping -w 4 www.baidu.com ");
InputStream is1 = pro.getInputStream();
BufferedReader buf = new BufferedReader(new InputStreamReader(is1));
String line = null;
while ((line = buf.readLine()) != null) {
if (line.indexOf("請求超時。") > -1) {
System.out.println("error");
break;
}
}
} catch (Exception e) {
// TODO: handle exception
}
// end
}
}
java執行客戶端命令(windows與linux通用)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.