hai, i need help

3 views
Skip to first unread message

subbu

unread,
Jun 29, 2009, 9:21:40 PM6/29/09
to "Code For Freedom" Contest Participants
hello,
i want to run this program in the background and it must display the
information to user if ping result is
"Request Timed Out" how can i do it, please guide me.
import java.net.*;
import java.io.*;
import java.util.*;

public class pingTest {

public static void main(String[] args) {

String ip = args[0];
String pingResult = "";

String pingCmd = "ping " + ip;

try {
Runtime r = Runtime.getRuntime();
Process p = r.exec(pingCmd);

BufferedReader in = new BufferedReader(new
InputStreamReader(p.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
System.out.println(inputLine);
pingResult += inputLine;
}

in.close();

}//try

catch (IOException e) {
System.out.println(e);

}
}
}
Reply all
Reply to author
Forward
0 new messages