public static boolean isValidURL(String url){
  URL u=null;
  try {
    u=new URL(url);
  }
 catch (  MalformedURLException e) {
    return false;
  }
  try {
    u.toURI();
  }
 catch (  URISyntaxException e) {
    return false;
  }
  return true;
}

public static boolean isValidURL ( String url ) { URL u = null ; try { u = new URL ( url ) ; } catch ( MalformedURLException e ) { return false ; } try { u . toURI ( ) ; } catch ( URISyntaxException e ) { return false ; } return true ; }
checks if the url is valid
