Java Path File List nio listFiles(final Path path)

Here you can find the source of listFiles(final Path path)

Description

list Files

License

Open Source License

Declaration

public static List<Path> listFiles(final Path path) throws IOException 

Method Source Code


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

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class Main {
    public static List<Path> listFiles(final Path path) throws IOException {
        List<Path> paths = new ArrayList<>();
        listFiles(path, paths);/*from  w ww. j  a  va2  s  .  co  m*/
        return paths;
    }

    public static void listFiles(final Path path, final List<Path> paths) throws IOException {
        if (Files.isDirectory(path)) {
            List<Path> files = Files.list(path).collect(Collectors.toList());
            for (Path path1 : files) {
                listFiles(path1, paths);
            }
        } else {
            paths.add(path);
        }
    }
}

Related

  1. listChildren(Path dir, boolean searchDirectory)
  2. listChildren(Path directory)
  3. listChildren(Path directory)
  4. listDir(Path dir)
  5. listDirsRecursive(String pathStr, String pattern, int maxDepth)
  6. listFiles(Path base, StringBuilder b)
  7. listFiles(Path basePath)
  8. listFiles(Path dir)
  9. listFiles(Path dir, String glob)