String cmd = "ping 127.0.0.1 -t";
Runtime rt = Runtime.getRuntime();
System.out.println(""+cmd );
Process process = rt.exec(cmd );
InputStream stdin = process.getInputStream();
InputStreamReader isr = new InputStreamReader(stdin);
BufferedReader br = new BufferedReader(isr);
String line;
StringBuffer buf = new StringBuffer();
while ((line = br.readLine()) != null) {
buf.append(line);
System.out.println(line);
}
int exitVal = process.waitFor();
System.out.println("Process exitValue: " + exitVal);