import java.io.BufferedReader;
import java.io.InputStreamReader;
public class testMain {
/**
* @param args
* @throws
*
*/
public static void main(String[] args){
StringBuilder cmdBuilder = new StringBuilder("ping www.baidu.com");
String cmd = cmdBuilder.toString();
Runtime run = Runtime.getRuntime();
Process p;
try {
p=run.exec(cmd);
BufferedReader br = new BufferedReader(new InputStreamReader(
p.getInputStream(),"GBK"));
String inline;
while ((inline = br.readLine()) != null) {
System.out.println(inline);
}
br.close();
} catch (Exception e) {
System.out.println("失败");
}
}
}
import java.io.InputStreamReader;
public class testMain {
/**
* @param args
* @throws
*
*/
public static void main(String[] args){
StringBuilder cmdBuilder = new StringBuilder("ping www.baidu.com");
String cmd = cmdBuilder.toString();
Runtime run = Runtime.getRuntime();
Process p;
try {
p=run.exec(cmd);
BufferedReader br = new BufferedReader(new InputStreamReader(
p.getInputStream(),"GBK"));
String inline;
while ((inline = br.readLine()) != null) {
System.out.println(inline);
}
br.close();
} catch (Exception e) {
System.out.println("失败");
}
}
}