Java tutorial
import java.net.URI; public class Main { public static void main(String... args) throws Exception { String url = "http://www.java2s.com/Tutorials/Java/Algorithms_How_to/index.htm"; URI u = new URI(url); for (String ext : new String[] { ".png", ".pdf", ".jpg", ".html", "htm" }) { if (u.getPath().endsWith(ext)) { System.out.println("Yeap"); break; } } } }