Java tutorial
//package com.java2s; //License from project: Apache License public class Main { private static final String[] ACCEPTS_IMAGE = new String[] { "jpeg", "jpg", "png", "webp" }; public static boolean hasExtension(String filename) { int index = filename.lastIndexOf("."); if (index > -1) { String extension = filename.substring(index + 1).toLowerCase(); for (String accept : ACCEPTS_IMAGE) { if (accept.equals(extension)) { return true; } } } return false; } }