Here you can find the source of getFileExtension(String fileName)
public static String getFileExtension(String fileName)
//package com.java2s; //License from project: Open Source License import java.io.File; public class Main { public static String getFileExtension(File file) { return getFileExtension(file.getName()); }//w w w . j a v a2 s . c o m public static String getFileExtension(String fileName) { int i = fileName.lastIndexOf('.'); int p = Math.max(fileName.lastIndexOf('/'), fileName.lastIndexOf('\\')); if (i > p) { return fileName.substring(i + 1); } return ""; } }