方法一:
使用lastIndexOf()方法,从后向前,直接截取最后一部分
String newName = fileName.substring(fileName.lastIndexOf("/")+1);
方法二:
使用全切割方法
String dirDiveded[] = fileName.split("/");
String newName = "";
if(dirDiveded.length > 0){
newName = dirDiveded[dirDiveded.length-1];
}
标签:lastIndexOf,String,newName,元素,fileName,获取,split,dirDiveded
From: https://www.cnblogs.com/baozhengrui/p/17628779.html