Java Folder Read GetFilesWithChildren(File root, ArrayList files)

Here you can find the source of GetFilesWithChildren(File root, ArrayList files)

Description

Gets all files with child directory

License

Apache License

Parameter

Parameter Description
root a parameter
files a parameter

Return

all files with absolutePath

Declaration

public static ArrayList<String> GetFilesWithChildren(File root, ArrayList<String> files) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.File;

import java.util.ArrayList;

public class Main {
    /**//from w ww  .  j  ava2 s. co  m
     * Gets all files with child directory
     * @param root
     * @param files
     * @return all files with absolutePath
     */
    public static ArrayList<String> GetFilesWithChildren(File root, ArrayList<String> files) {

        File[] list = root.listFiles();

        if (list == null)
            return files;

        for (File p : list) {

            if (p.isDirectory()) {

                GetFilesWithChildren(p, files);
            } else {

                files.add(p.getAbsolutePath());
            }
        }

        return files;
    }
}

Related

  1. getFilesStartingWith(String dirName, String startsWith)
  2. getFileStatus(File file)
  3. getFileString(File file)
  4. getFileString(String filePath)
  5. getFileStringContent(String filename)
  6. getFileSystemProperties(String path)
  7. getFileSystemProperty(String name)