public static String getExtension(String filename)
    {
        int i = filename.lastIndexOf('.');
        int j = filename.lastIndexOf(File.separatorChar);

        return (i > 0 && i > j && i < filename.length() - 1) ? filename
                .substring(i + 1).toLowerCase() : "";
    }