Here you can find the source of getFileName(File f)
public static String getFileName(File f)
//package com.java2s; import java.io.File; public class Main { public static String getFileName(File f) { String ext = null;/* w w w . j a va 2 s . co m*/ String s = f.getName(); int i = s.lastIndexOf(File.pathSeparatorChar); if (i > 0 && i < s.length() - 1) { ext = s.substring(i + 1).toLowerCase(); } return ext; } }