Java tutorial
//package com.java2s; import java.io.File; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static String getFileName(String path) { Pattern pattern = Pattern.compile("[^\\" + File.separator + "]+.xml"); Matcher matcher = pattern.matcher(path); if (matcher.find()) return matcher.group().substring(0, matcher.group().length() - 4); return ""; } }