Here you can find the source of extractFileName(String filePathName)
public static String extractFileName(String filePathName)
//package com.java2s; //License from project: Open Source License public class Main { public static String extractFileName(String filePathName) { if (filePathName == null) { return null; }// w w w .j a va2 s.co m int dotPos = filePathName.lastIndexOf('.'); int slashPos = filePathName.lastIndexOf('\\'); if (slashPos == -1) { slashPos = filePathName.lastIndexOf('/'); } if (dotPos > slashPos) { return filePathName.substring(slashPos > 0 ? slashPos + 1 : 0, dotPos); } return filePathName.substring(slashPos > 0 ? slashPos + 1 : 0); } }