I want to get the ping execution time and result in string after ping host. How can I do it?
long start = System.currentTimeMillis();
long ping;
String[] command = { "cmd.exe", "/C", "ping 192.168.1.101" };
commandProcess = Runtime.getRuntime().exec(command);
BufferedReader buffy = new BufferedReader(new InputStreamReader(commandProcess.getInputStream()));
String readline;
while((readline = buffy.readLine())!=null){
System.out.println(readline);
if(readline.contains("reply")){
long ping = System.currentTimeMillis();
System.out.println("Pinged in:"+ ping);
}
}
long end = System.currentTimeMillis();
String done = "Completed in times:" +start + ping +end;