Android URL String Validate isValidUrl(String linkToCheck)

Here you can find the source of isValidUrl(String linkToCheck)

Description

is Valid Url

Declaration

public static boolean isValidUrl(String linkToCheck) 

Method Source Code

//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*/
}

Related

  1. isUrl(String s)