Java tutorial
//package com.java2s; public class Main { public static String fileName(String path) { if (!isEmpty(path)) { // adapted from DropboxAPI.java v1.5.4 if (path.endsWith("/")) { path = path.substring(0, path.length() - 1); } int ind = path.lastIndexOf('/'); return path.substring(ind + 1, path.length()); } return ""; } public static boolean isEmpty(String s) { return s == null || s.trim().length() == 0; } }