Here you can find the source of isUrl(String s)
public static boolean isUrl(String s)
//package com.java2s; //License from project: Apache License import java.util.regex.Pattern; public class Main { public static boolean isUrl(String s) { if (isEmpty(s)) return false; boolean ret = Pattern.matches("^(https|http|ftp|rtsp|mms)?:\\/\\/[^\\s]*$", s); if (!ret) ret = Pattern.matches("^[\\.\\/\\?#a-zA-Z0-9-_=&;,%]*$", s); return ret; }//from ww w. j a va 2 s . co m public static boolean isEmpty(String str) { return str == null || (str.trim().length() == 0); } }