`
Yinny
  • 浏览: 292527 次
  • 性别: Icon_minigender_2
  • 来自: 杭州
社区版块
存档分类
最新评论

一个简单的Java(string)截取图片的后缀程序

阅读更多
Java代码  
public static String getPicSuffix(String img_path){  
   if (img_path == null || img_path.indexOf(".") == -1){  
        return ""; //如果图片地址为null或者地址中没有"."就返回""  
   }  
   return img_path.substring(img_path.lastIndexOf(".") + 1).  
          trim().toLowerCase();  
}  
          
  
   //img_path.lastIndexOf(".")返回最后一次出现的.在此字符串中的索引。  
    //img_path.substring(img_path.lastIndexOf(".") + 1)返回一个新的字符串  
    //trim()清空空格  
    //toLowerCase()转化成小写  
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics