如何获得名称中包含多个点的文件扩展名?
例如:
image.fromyesterday.hello.jpg
提前致谢!
String something = "image.fromyesterday.hello.jpg";
String extension = something.substring(something.lastIndexOf("."));
我认为这会更好:
String suffixOf(String name){
if(name == null || name.equals("")){
return "";
}
String suffix = "";
int index = name.lastIndexOf(".");
if (index != -1 ) {
suffix = name.substring(index + 1);
}
return suffix;
}