Here you can find the source of isImageUrl(String imgUrl)
public static boolean isImageUrl(String imgUrl)
//package com.java2s; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static boolean isImageUrl(String imgUrl) { if (isEmptyOrNull(imgUrl)) { return false; }/*from w ww . ja va 2s. c om*/ String regEx = "([^\\s]+(\\.(?i)(jpg|png|gif))$)"; Pattern pattern = Pattern.compile(regEx); Matcher matcher = pattern.matcher(imgUrl); return matcher.matches(); } public static boolean isEmptyOrNull(String str) { return str == null || str.length() == 0 || str.contentEquals("null") || str.trim().equals(""); } }