举例:String
fName =” G:\Java_Source\navigation_tigra_menu\demo1\img\lev1_arrow.gif ”
方法一:
1
2
3
|
File tempFile =new File( fName.trim());
String fileName = tempFile.getName();
|
方法二:
1
2
3
|
String fName = fName.trim();
String fileName = fName.subString(fName.lastIndexOf("/")+1);
|
方法三:
1
2
3
4
5
|
String fName = fName.trim();
String temp[] = fName.split("\\\\"); /**split里面必须是正则表达式,"\\"的作用是对字符串转义*/
String fileName = temp[temp.length-1];
|