Here you can find the source of isValidUrl(String input)
public static boolean isValidUrl(String input)
//package com.java2s; //License from project: Apache License import java.net.URI; import java.net.URL; public class Main { public static boolean isValidUrl(String input) { if (!input.startsWith("http://") && !input.startsWith("https://")) { input = ("http://" + input); }/* w w w.j ava 2 s . co m*/ try { URI uri = new URI(input); URL url = uri.toURL(); java.net.URLConnection conn = url.openConnection(); conn.connect(); return true; } catch (Exception ignored) { } return false; } }