Here you can find the source of isValidUrl(String linkToCheck)
public static boolean isValidUrl(String linkToCheck)
//package com.java2s; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static boolean isValidUrl(String linkToCheck) { Pattern urlPattern = Pattern .compile("^((https?:\\/\\/(www)?)|(www)).+(\\..{2,4})(\\/)?.+$"); Matcher urlMatcher = urlPattern.matcher(linkToCheck); return urlMatcher.matches(); }/*from w w w. j a v a 2s . c o m*/ }