Java Path File List nio listFiles(Path path)

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

Description

list Files

License

Open Source License

Declaration

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

Method Source Code

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

import java.io.IOException;

import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;

import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;

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

public class Main {
    static List<Path> listFiles(Path path) throws IOException {
        final List<Path> result = new ArrayList<>();

        Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
            @Override//from w  ww  . java  2  s. com
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                result.add(file);
                return FileVisitResult.CONTINUE;
            }
        });

        return result;
    }
}

Related

  1. listFiles(Path dir)
  2. listFiles(Path dir, String glob)
  3. listFiles(Path directory)
  4. listFiles(Path directory, String glob)
  5. listFiles(Path path)
  6. listFiles(Path path, List preorderList)
  7. listFiles(Path path, String glob)
  8. listFilesRecursively(Path dir, final DirectoryStream.Filter filter, final boolean recursive)
  9. listFoldersInFolder2(String path)