how to check an url connection.

how to check an url connection in java, like ping.say i want to check to java.sun.com. do i have connection to that url or not.
[148 byte] By [ariwicak] at [2007-9-26 4:09:04]
# 1

This is from memory, but try something like:

URL url = new URL("http://java.sun.com");

try {

URLConnection conn = url.getConnection();

}

catch (IOException e) {

System.out.println("No connection to java.sun.com");

}

bkbagnall at 2007-6-29 13:11:46 > top of Java-index,Archived Forums,Java Programming...
# 2
sorry, it's url.openConnection()
bkbagnall at 2007-6-29 13:11:46 > top of Java-index,Archived Forums,Java Programming...