Java tutorial
//package com.java2s; //License from project: Open Source License public class Main { public static String getFileExtensionName(String fileName) { String extensionName = ""; if (!isEmpty(fileName) && fileName.lastIndexOf(".") >= 0) { extensionName = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase(); } return extensionName; } public static boolean isEmpty(String input) { if (input == null || "".equals(input) || "null".equals(input.toLowerCase())) return true; for (int i = 0; i < input.length(); i++) { char c = input.charAt(i); if (c != ' ' && c != '\t' && c != '\r' && c != '\n') { return false; } } return true; } }