String regex = ".*\\\\([^\\.]+)\\..*"
input.replaceAll(regex, "$1")
用 fname举个例子String fName =" G:\\Java_Source\\navigation_tigra_menu\\demo1\\img\\lev1_arrow.gif "
fName = fName.trim()
String temp[] = fName.split("\\\\") /**split里面必须是正则表达式,"\\"的作用是对字符串转义*/
//temp[] = [G:, Java_Source, navigation_tigra_menu, demo1, img, lev1_arrow.gif]
System.out.println("temp[] = " + Arrays.toString(temp))
fName = temp[temp.length-1]
System.out.println("方法三:fileName = " + fName)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)