Here you can find the source of isAValidURL(String url)
public static boolean isAValidURL(String url)
//package com.java2s; //License from project: Apache License import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; public class Main { public static boolean isAValidURL(String url) { URL u = null;/*from ww w . ja v a 2 s . c o m*/ HttpURLConnection huc = null; try { u = new URL(url); huc = (HttpURLConnection) u.openConnection(); huc.setRequestMethod("HEAD"); huc.connect(); return (huc.getResponseCode() == HttpURLConnection.HTTP_OK); } catch (IOException e) { e.printStackTrace(); } finally { if (huc != null) huc.disconnect(); } return false; } }