subbu
unread,Jun 29, 2009, 9:21:40 PM6/29/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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);
}
}
}