is string a Valid Url - Android java.net

Android examples for java.net:URL

Description

is string a Valid Url

Demo Code

import android.text.TextUtils;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{

    public static boolean isValidUrl(String url) {


        String strPattern = "^(http|https)://(.+)/(.+)([.]+)(.+)$";
        Pattern p = Pattern.compile(strPattern);
        Matcher m = p.matcher(url);
        return m.matches();
    }/*from   w  w w .  ja  v a 2s .c o m*/

}

Related Tutorials