can anybody help me? I have code:
public class Demo {
String lineValue;
public void execute () {String a[] = new String[] { "ping google.com", "ping youtube.com" };
for (int i = 0; i < a.length; i++) {
try {
Process process = Runtime.getRuntime().exec(a[i]);
BufferedReader reader = new BufferedReader(
new InputStreamReader(process.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
// System.out.println(line);
lineValue=line;
}
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
public String getLineValue() {
System.out.println(lineValue);
return lineValue;
}
and
public class Test {
String result;
public static void main(String[] args) {
Test t = new Test();
Demo d = new Demo();
d.execute();
d.getLineValue();
}
}
the result is
Minimum = 23ms, Maximum = 29ms, Average = 25ms
but i want get something like this
Pinging google.com [216.58.209.206] with 32 bytes of data:
Reply from 216.58.209.206: bytes=32 time=23ms TTL=56
Reply from 216.58.209.206: bytes=32 time=23ms TTL=56
Request timed out.
Reply from 216.58.209.206: bytes=32 time=24ms TTL=56
Ping statistics for 216.58.209.206:
Packets: Sent = 4, Received = 3, Lost = 1 (25% loss),
Approximate round trip times in milli-seconds:
Minimum = 23ms, Maximum = 24ms, Average = 23ms
Pinging youtube.com [216.58.209.174] with 32 bytes of data:
Reply from 216.58.209.174: bytes=32 time=24ms TTL=55
Reply from 216.58.209.174: bytes=32 time=24ms TTL=55
Reply from 216.58.209.174: bytes=32 time=23ms TTL=55
Reply from 216.58.209.174: bytes=32 time=29ms TTL=55
Ping statistics for 216.58.209.174:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 23ms, Maximum = 29ms, Average = 25ms