Here you can find the source of isValidUrl(String url)
public static boolean isValidUrl(String url)
//package com.java2s; import android.text.TextUtils; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static boolean isValidUrl(String url) { if (isBlank(url)) return false; String strPattern = "^(http|https)://(.+)/(.+)([.]+)(.+)$"; Pattern p = Pattern.compile(strPattern); Matcher m = p.matcher(url); return m.matches(); }/*from ww w . jav a2 s . c o m*/ /** * Whether the String is null, zero-length and does contain only whitespace */ public static boolean isBlank(String text) { if (isEmpty(text)) return true; for (int i = 0; i < text.length(); i++) { if (!Character.isWhitespace(text.charAt(i))) return false; } return true; } /** * Whether the given string is null or zero-length */ public static boolean isEmpty(String text) { return TextUtils.isEmpty(text); } }