Here you can find the source of getFilename(File file)
public static String getFilename(File file)
//package com.java2s; //License from project: BSD License import java.io.File; public class Main { public static String getFilename(File file) { return getFilename(file.getName()); }//from ww w .j a va2 s .c o m public static String getFilename(String file) { String name = file; int index = name.lastIndexOf("\\"); if (index > -1) { name = name.substring(index + 1, name.length()); } else { index = name.lastIndexOf("/"); if (index > -1) name = name.substring(index + 1, name.length()); } return name; } }