Here you can find the source of fileName(String path)
public static String fileName(String path)
//package com.java2s; //License from project: Apache License public class Main { /**/*from ww w . j a v a2s. c o m*/ * returns the filename from the given path */ public static String fileName(String path) { int pos = Math.max(path.lastIndexOf('/'), path.lastIndexOf('\\')); if (pos > 0) { return path.substring(pos + 1); } return path; } }