Java tutorial
//package com.java2s; import android.text.TextUtils; public class Main { public static boolean isImageFile(String suffix) { if (TextUtils.isEmpty(suffix)) { return false; } if (suffix.startsWith(".")) { suffix = suffix.substring(1); } String imageFormat[] = new String[] { "JPEG", "JPG", "BMP", "PNG" }; for (int i = 0; i < imageFormat.length; i++) { if (suffix.equalsIgnoreCase(imageFormat[i])) { return true; } } return false; } /** * Returns true if the string is null or 0-length. * * @param str * the string to be examined * @return true if str is null or zero length */ public static boolean isEmpty(CharSequence str) { if (str == null || str.length() == 0 || "null".equals(str.toString().trim())) return true; else return false; } }