Here you can find the source of getFileNames(List
public static List<String> getFileNames(List<String> fileNames, Path dir)
//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.util.List; import java.util.stream.Collectors; public class Main { public static List<String> getFileNames(List<String> fileNames, Path dir) { int foundFiles = 0; try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir)) { for (Path path : stream) { if (path.toFile().isDirectory()) { getFileNames(fileNames, path); } else { foundFiles++;/*from www.j av a2 s . c om*/ fileNames.add(path.toAbsolutePath().toString()); if ((foundFiles % 100) == 0) { System.out.print("."); } } } } catch (IOException e) { e.printStackTrace(); } return filterNotPoms(fileNames); } public static List<String> filterNotPoms(List<String> fileNames) { List<String> retRes = fileNames.stream().filter(path -> containPomXml(path)).collect(Collectors.toList()); return retRes; } private static boolean containPomXml(String aString) { if (aString.endsWith("pom.xml")) { return true; } else { return false; } } }