Here you can find the source of extractFileName(String path)
public static String extractFileName(String path)
//package com.java2s; //License from project: Open Source License public class Main { public static String extractFileName(String path) { int index = path.lastIndexOf("\\"); if (index > -1) { if (index < path.length() - 1) { return path.substring(index + 1); } else { return ""; }//from w w w . j av a 2 s. co m } index = path.lastIndexOf("/"); if (index > -1) { if (index < path.length() - 1) { return path.substring(index + 1); } else { return ""; } } return path; } }