Here you can find the source of getFileExtension(String fileName)
public static String getFileExtension(String fileName)
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { public static final char EXTENSION_SEPARATOR = '.'; public static String getFileExtension(String fileName) { String ext = null;// w ww . j a va 2s. co m int k = fileName.lastIndexOf(EXTENSION_SEPARATOR); // NOI18N if (k != -1) { ext = fileName.substring(k + 1, fileName.length()); } return ext; } public static String getFileExtension(File file) { return getFileExtension(file.getName()); } }