Java examples for java.util.regex:Match URL
is string an Image Url
import java.util.regex.Pattern; public class Main { public static void main(String[] argv) { String url = "http://java2s.com"; System.out.println(isImgUrl(url)); }/* w w w . j av a 2s . c o m*/ private final static Pattern IMG_URL = Pattern.compile(".*?(gif|jpeg|png|jpg|bmp)"); public static boolean isImgUrl(String url) { return !isEmpty(url) && IMG_URL.matcher(url).matches(); } public static boolean isEmpty(String str) { return str == null || str.trim().length() == 0 || str.trim().equalsIgnoreCase("null"); } }