Here you can find the source of getFilenameExtension(String path)
public static String getFilenameExtension(String path)
//package com.java2s; public class Main { private static final String FOLDER_SEPARATOR = "/"; private static final char EXTENSION_SEPARATOR = '.'; public static String getFilenameExtension(String path) { if (path == null) { return null; }/*from w w w. ja v a 2s .c om*/ int extIndex = path.lastIndexOf(EXTENSION_SEPARATOR); if (extIndex == -1) { return null; } int folderIndex = path.lastIndexOf(FOLDER_SEPARATOR); if (folderIndex > extIndex) { return null; } return path.substring(extIndex + 1); } }