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