Java tutorial
//package com.java2s; public class Main { public static String getFileName(String str) { if (isEmptyString(str)) { return null; } int start = str.lastIndexOf('/'); start++; int end = str.lastIndexOf('.'); if (end <= start) { return null; } return str.substring(start, end); } public static boolean isEmptyString(String str) { return str == null || str.trim().length() == 0 || "null".equals(str); } public static String trim(String text) { return text == null ? null : text.trim(); } }