首页 > 移动平台 > 详细

Android:获取指定文件夹内的所有图片

时间:2019-03-17 16:56:31      阅读:667      评论:0      收藏:0      [点我收藏+]
 1 public static List<String> getFilesAllName(String path){
 2     //传入指定文件夹的路径
    File file = new File(path); 3 File[] files = file.listFiles(); 4 List<String> imagePaths = new ArrayList<>(); 5 for(int i = 0; i < files.length; i++){ 6 if(checkIsImageFile(files[i].getPath())){ 7 imagePaths.add(files[i].getPath()); 8 } 9 10 } 11 return imagePaths; 12 } 13 14 /** 15 * 判断是否是照片 16 */ 17 public static boolean checkIsImageFile(String fName){ 18 boolean isImageFile = false; 19 //获取拓展名 20 String fileEnd = fName.substring(fName.lastIndexOf(".") + 1, 21 fName.length()).toLowerCase(); 22 if(fileEnd.equals("jpg") || fileEnd.equals("png") || fileEnd.equals("gif") 23 || fileEnd.equals("jpeg")|| fileEnd.equals("bmp")){ 24 isImageFile = true; 25 }else{ 26 isImageFile = false; 27 } 28 return isImageFile; 29 }

 

Android:获取指定文件夹内的所有图片

原文:https://www.cnblogs.com/Rainm/p/10547550.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!