Java Path File List nio listDir(Path dir)

Here you can find the source of listDir(Path dir)

Description

list Dir

License

Apache License

Declaration

public static List<Path> listDir(Path dir) throws IOException 

Method Source Code


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

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Stream;

public class Main {
    public static List<Path> listDir(Path dir) throws IOException {
        List<Path> contents = new LinkedList<>();
        try (Stream<Path> list = Files.list(dir)) {
            list.forEach(contents::add);
        }/*from  w w  w  . j  ava 2s  . c o  m*/
        return contents;
    }
}

Related

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