Here you can find the source of checkStringIsUrl(String input)
public static boolean checkStringIsUrl(String input)
//package com.java2s; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static boolean checkStringIsUrl(String input) { if (input == null) return false; if (input.indexOf("tel://") == 0) { return true; }/* www .jav a 2 s. co m*/ if (input.indexOf("mailto:") == 0 && input.contains("@")) { return true; } if (input.indexOf("wtai://") == 0) { return true; } Pattern pattern = Pattern .compile( "(^((https|http|ftp|rtsp|mms)?://)" + "?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?" + "(([0-9]{1,3}\\.){3}[0-9]{1,3}" + "|" + "([0-9a-z_!~*'()-]+\\.)*" + "([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\\." + "[a-z]{2,6})" + "(:[0-9]{1,4})?" + "((/?)|" + "(/[0-9a-z\\u4e00-\\u9fa5_!~*'().;?:@&=+$,%#-/]+)+/?)$)|(^file://*)", Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(input.trim()); if (matcher.find()) { return true; } else { return false; } } }