Android Directory Content Get getFileInDirectory(File f)

Here you can find the source of getFileInDirectory(File f)

Description

get File In Directory

Declaration

public static List<File> getFileInDirectory(File f) 

Method Source Code

//package com.java2s;

import java.io.File;

import java.util.ArrayList;
import java.util.List;

public class Main {
    public static List<File> getFileInDirectory(File f) {

        List<File> list = getFileList(f);

        boolean check = true;
        while (check) {
            check = false;//from  w w  w  .ja  v  a  2 s.co  m

            List<File> listtmp = list;
            List<File> listtmp2 = new ArrayList<File>();
            ;

            for (File checktmp : listtmp) {
                if (checktmp.isFile()) {
                    listtmp2.add(checktmp);
                }

                if (checktmp.isDirectory()) {
                    check = true;

                    for (File f2 : getFileList(checktmp)) {
                        listtmp2.add(f2);
                    }
                }
            }

            list = listtmp2;
        }

        return list;
    }

    public static List<File> getFileList(File f) {
        List<File> list = new ArrayList<File>();

        for (File tmp : f.listFiles()) {
            list.add(tmp);
        }

        return list;
    }
}

Related

  1. getFiles(File parentDir)
  2. getFilesAndSubFolderFiles(List fileList, File rootDir)
  3. listDirs(File file)
  4. listDirs(String fileName)