I need to check whether a particular url is up or not. The format of the url is like
http://IP:port When I use java.net.URL class then I get java.net.SocketException or java.net.ConnectException.
When i ping these IPs, I find them up then why java is not able to recognise them?
The code I'm writing is
URL url = new URL( urlString ); HttpURLConnection httpConn = (HttpURLConnection)url.openConnection(); httpConn.setInstanceFollowRedirects( false ); httpConn.setRequestMethod( "HEAD" ); httpConn.connect(); Port number is must to use! How can I check them using java?