【 tulaoshi.com - 编程语言 】
1.截取不带后缀的文件名 String resourceName=resourceSearchBean.getFileName();
if(StringHelper.isNotEmpty(resourceName)&&resourceName.length()0);
{
int dot = resourceName.lastIndexOf('.');
if ((dot -1) && (dot (resourceName.length()))) {
return resourceName.substring(0, dot);
}
}
2.截取文件后缀名 代码如下:
public static String getExtensionName(String filename) {
if ((filename != null) && (filename.length() 0)) {
int dot = filename.lastIndexOf('.');
if ((dot -1) && (dot (filename.length() - 1))) {
return filename.substring(dot + 1);
}
}
return filename;
}