Java tutorial
//package com.java2s; import java.io.File; public class Main { private static String getFileNameFromPath(String filePath) { int begin = filePath.lastIndexOf(File.separator); int end = filePath.lastIndexOf("."); if (end < 1) { return null; } String fileName = filePath.substring(begin + 1, end); return fileName; } }