Here you can find the source of getFileName(String filePath)
public static String getFileName(String filePath)
//License from project: Apache License import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.net.URL; import java.nio.ByteBuffer; import java.nio.charset.Charset; import java.util.regex.Pattern; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class Main{ public static String getFileName(String filePath) { if (StringUtil.isEmpty(filePath)) { return null; }//from www .j av a 2 s .c o m int pos = filePath.lastIndexOf(File.separator); if (pos == -1) { return null; } return filePath.substring(pos + 1); } }