Java Path File List nio listFoldersInFolder2(String path)

Here you can find the source of listFoldersInFolder2(String path)

Description

list Folders In Folder

License

Open Source License

Declaration

public static List<String> listFoldersInFolder2(String path) 

Method Source Code

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

import java.io.IOException;

import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static List<String> listFoldersInFolder2(String path) {
        List<String> filesInFolder = new ArrayList<String>();
        // Path reportFileNameP = Paths.get(path,"report.xml");
        Path pathP = Paths.get(path);

        try {//w  w  w . ja  v  a2s. com
            DirectoryStream<Path> rootStream = Files.newDirectoryStream(pathP);
            for (Path folderName : rootStream) {
                filesInFolder.add(folderName.getFileName().toString());
            }

        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        return filesInFolder;
    }
}

Related

  1. listFiles(Path path)
  2. listFiles(Path path)
  3. listFiles(Path path, List preorderList)
  4. listFiles(Path path, String glob)
  5. listFilesRecursively(Path dir, final DirectoryStream.Filter filter, final boolean recursive)
  6. listOfWords(String filePath)
  7. listSteps(Path scenarioDirectory)
  8. loadDataFilesList(String prefix, Path bwcIndicesPath)
  9. loadTrainingData(Path path, List input, List output, int outputCount)