public static void main(String[] args) throws IOException, InterruptedException {
// 執行ping命令
String cmdPing = "ping 127.0.0.1";
Runtime run = Runtime.getRuntime();
Process process = run.exec(cmdPing);
process.waitFor();
BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream(), Charset.forName("GBK")));
String line = null;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
}