Java Path File List nio getPreorderList(Path root)

Here you can find the source of getPreorderList(Path root)

Description

Get a list of all files and subfiles in the root directory.

License

Open Source License

Parameter

Parameter Description
root a parameter

Declaration

public static List<Path> getPreorderList(Path root) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.File;
import java.nio.file.Path;

import java.util.ArrayList;

import java.util.List;

public class Main {
    /**//from  www.  jav  a  2s .  c  o  m
     * Get a list of all files and subfiles in the root directory. The files are visited and returned in
     * preorder
     * 
     * @param root
     * @return
     */
    public static List<Path> getPreorderList(Path root) {
        List<Path> allFiles = new ArrayList<Path>();
        listFiles(root, allFiles);
        return allFiles;
    }

    private static void listFiles(Path path, List<Path> preorderList) {
        preorderList.add(path);
        File[] listFiles = path.toFile().listFiles();
        if (listFiles != null)
            for (File child : listFiles) {
                listFiles(child.toPath(), preorderList);
            }
    }
}

Related

  1. deepListChildren(Path directory)
  2. fileListDeep(Path dir)
  3. findExpectedResultForTestcase(final Path testcase, final LinkedList expectedResults)
  4. getClassLoaderFromPaths(ArrayList paths)
  5. getDirectoryList(Path basePath)
  6. getSortedPathList(final Path dir, final boolean dirsFirst)
  7. getTables(final List d1)
  8. isBlackListedDirectory(Path path)
  9. isPlaylistFile(Path testFile)