Android examples for android.graphics:Image
is File name an Image
import java.util.StringTokenizer; public class Main { public static boolean isImage(String filename) { StringTokenizer token = new StringTokenizer(filename); String name = ""; String end_pref = ""; int index = 0; String[] filetype = { "jpg", "gif", "bmp", "tif", "png", "ico" }; boolean is = false; while (token.hasMoreTokens()) { name = token.nextToken();/*from w w w .ja va2 s. c o m*/ } index = name.indexOf("."); end_pref = name.substring(index + 1); for (int i = 0; i < filetype.length; i++) { if (end_pref.equalsIgnoreCase(filetype[i])) { is = true; break; } } return is; } }