If I have understood you correctly,
you need to write a simple Java class (say MyURLPing.java) which takes the URL name as the argument from the command line and does a ping using the java library class
HttpURLConnection.java .
you run your class as follows:
Code:
C:/> java MyURLPing "www.google.com"
your main class will look something like
Code:
public class MyURLPing {
public static void main(String[] args) {
String url = args[0]; //eg www.google.com
try {
URL u = new URL(url);//
HttpURLConnection huc = (HttpURLConnection) u.openConnection();
huc.setRequestMethod("PUT");
huc.connect();
OutputStream os = huc.getOutputStream();
int code = huc.getResponseCode();
if (code >= 200 ) {
// put the data...
}
huc.disconnect();
}
catch (IOException e) { //...
}
}
hope this helps.
Bookmarks