Java tutorial
//package com.java2s; public class Main { public static String getOnlyFileName(String name) { String retStr = name; if (name.indexOf("/") >= 0) { retStr = name.substring(name.lastIndexOf("/") + 1); } else if (name.indexOf("\\") >= 0) { retStr = name.substring(name.lastIndexOf("\\") + 1); } return retStr; } }