Here you can find the source of getFileExtensionFromName(String filename)
public static String getFileExtensionFromName(String filename)
//package com.java2s; //License from project: Apache License public class Main { public static String getFileExtensionFromName(String filename) { if (filename == null) { return null; }/*from w w w.ja v a 2 s .c om*/ int index = indexOfExtension(filename); if (index == -1) { return ""; } else { return filename.substring(index + 1); } } private static int indexOfExtension(String filename) { if (filename == null) { return -1; } int extensionPos = filename.lastIndexOf("."); int lastSeparator = filename.lastIndexOf("/"); return (lastSeparator > extensionPos ? -1 : extensionPos); } }