Here you can find the source of getFileExtension(File file)
public static String getFileExtension(File file)
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static String getFileExtension(File file) { if (file == null) return null; int extPos = file.getAbsolutePath().lastIndexOf("."); int sepPos = file.getAbsolutePath().lastIndexOf(File.pathSeparator); if (extPos == -1) return null; if (sepPos > extPos) return null; return file.getAbsolutePath().substring(extPos + 1); }/*from ww w . j a v a 2s. c om*/ }