How Do I check if I can connect to a system from java

From my program I want to check if I can connect to a URL if not exit gracefully
vas1Asked:
Who is Participating?
 
aziz061097Connect With a Mentor Commented:
SecurityManager sm = System.getSecurityManager();

if (security != null)
{
try
  {
  sm.checkConnect("www.experts-exchange.com",80);
  }
  catch(SecurityException ex)
  {
   // catch exceptions
  }
}
0
 
vas1Author Commented:
Thanks for the prompt reply . I think this will work. Thanks again.
0
All Courses

From novice to tech pro — start learning today.