zoukankan      html  css  js  c++  java
  • Android 遍历文件夹,搜索指定扩展名的文件

    private List<String> lstFile = new ArrayList<String>();  //结果 List
    
    public void GetFiles(String Path, String Extension, boolean IsIterative)  //搜索目录,扩展名,是否进入子文件夹
    {
    	File[] files = new File(Path).listFiles();
    
    	for (int i = 0; i < files.length; i++)
    	{
    		File f = files[i];
    		if (f.isFile())
    		{
    			if (f.getPath().substring(f.getPath().length() - Extension.length()).equals(Extension))  //判断扩展名
    				lstFile.add(f.getPath());
    
    			if (!IsIterative)
    				break;
    		}
    		else if (f.isDirectory() && f.getPath().indexOf("/.") == -1)  //忽略点文件(隐藏文件/文件夹)
    			GetFiles(f.getPath(), Extension, IsIterative);
    	}
    }
    

      

  • 相关阅读:
    9月9号作业
    9月9号笔记
    jupyter的补充
    jupyter的使用
    9月6号作业
    编程语言的分类
    计算机组成
    计算机组成的补充
    面向对象基础
    9月2号作业
  • 原文地址:https://www.cnblogs.com/andgoo/p/2676420.html
Copyright © 2011-2022 走看看