Java tutorial
//package com.java2s; public class Main { public static String getFilenameFromPath(String path) { if (path == null) { throw new IllegalArgumentException("path cannot be null"); } int lastIndexOf = path.lastIndexOf("/"); if (lastIndexOf == -1) { return path; } return path.substring(lastIndexOf + 1, path.length()); } }