Java tutorial
//package com.java2s; import java.io.File; import java.util.Locale; public class Main { public static String getExtensionFromFileName(String fileName) { int slash = fileName.lastIndexOf(File.separatorChar); int dot = fileName.lastIndexOf('.'); if (slash >= dot) { return null; } String extension = fileName.substring(dot + 1).toLowerCase(Locale.ENGLISH); return extension; } }