Here you can find the source of getFileExtension(String filePath)
public static String getFileExtension(String filePath)
//package com.java2s; //License from project: Apache License import java.io.File; public class Main { public static String getFileExtension(String filePath) { if (filePath == null || filePath.trim().length() == 0) { return filePath; }//from w ww. jav a2 s . c o m int extenPosi = filePath.lastIndexOf("."); int filePosi = filePath.lastIndexOf(File.separator); if (extenPosi == -1) { return ""; } return (filePosi >= extenPosi) ? "" : filePath.substring(extenPosi + 1); } }