Here you can find the source of getFileExtension(String name)
public static String getFileExtension(String name)
//package com.java2s; import java.io.File; public class Main { public static String getFileExtension(String name) { int iIndex = name.lastIndexOf('.'); if (iIndex >= 0) { return name.substring(iIndex); }/*from w w w. j a v a 2 s . c om*/ return null; } public static String getFileExtension(File file) { String name = file.getName(); return getFileExtension(name); } }