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;
}