Here you can find the source of listFoldersInFolder2(String path)
public static List<String> listFoldersInFolder2(String path)
//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; } }