Here you can find the source of fileName(String path)
public static String fileName(String path)
//package com.java2s; //License from project: Open Source License public class Main { public static String fileName(String path) { if (path.endsWith("/")) { throw new IllegalArgumentException("path cannot end with a slash"); }//from w w w .j a v a 2 s . c om int indexOfLastSeparator = path.lastIndexOf('/'); if (indexOfLastSeparator == -1) { throw new IllegalArgumentException("path does not contain any slashes"); } return path.substring(indexOfLastSeparator + 1); } }