Java Directory to File List getAllFile(List list, File rootFile)

Here you can find the source of getAllFile(List list, File rootFile)

Description

recursively get the file list.

License

Open Source License

Parameter

Parameter Description
list a parameter
rootFile a parameter

Declaration

public static List<File> getAllFile(List<File> list, File rootFile) 

Method Source Code

//package com.java2s;

import java.io.File;

import java.util.Arrays;
import java.util.List;

public class Main {
    /**//from  ww  w. j av a 2s. co  m
     * recursively get the file list.
     * 
     * @param list
     * @param rootFile
     * @return
     */
    public static List<File> getAllFile(List<File> list, File rootFile) {

        if (rootFile.getAbsolutePath().indexOf(".svn") < 0) {
            list.add(rootFile);
            if (rootFile.isDirectory()) {
                File[] files = rootFile.listFiles();
                Arrays.sort(files);
                for (File file : files) {
                    getAllFile(list, file);
                }
            }
        }
        return list;
    }

    /**
     * determine if the file is directory .
     * 
     * @param path
     * @return
     */
    public static boolean isDirectory(String path) {
        return new File(path).isDirectory();
    }
}

Related

  1. getAllFile(File directory, boolean descendIntoSubDirectories, String endofFile, String hiddenFileSuffix)
  2. getAllFile2(String Url)
  3. getAllFileFromPath(File file, List fileList, String ed)
  4. getAllFileName(String path)
  5. GetAllFileName(String path)