Algorithm:
Step 1: Start the program.
Step 2: Import net and packages.
Step 3: Get the ip address
Step 4: Ping the remote server using Ping Command
Step 5: The Packet statistics of the pinged server is displayed
Program:
import java.net.*;
import java.io.*;
import java.util.*;
public class pingTest {
public static void main(String[] args) {
String ipa = args[0];
String pingResult = "";
String pingCmd = "ping " + ipa;
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);
}
}
}
Step 1: Start the program.
Step 2: Import net and packages.
Step 3: Get the ip address
Step 4: Ping the remote server using Ping Command
Step 5: The Packet statistics of the pinged server is displayed
Program:
import java.net.*;
import java.io.*;
import java.util.*;
public class pingTest {
public static void main(String[] args) {
String ipa = args[0];
String pingResult = "";
String pingCmd = "ping " + ipa;
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);
}
}
}