Here you can find the source of getAllFiles(List
Parameter | Description |
---|---|
fileNames | a parameter |
path | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static List<String> getAllFiles(List<String> fileNames, Path path) throws IOException
//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; public class Main { /**/*from ww w . j a v a2s . co m*/ * Collect all the files in a given path recursively * * @param fileNames * @param path * @return * @throws IOException */ public static List<String> getAllFiles(List<String> fileNames, Path path) throws IOException { try (DirectoryStream<Path> stream = Files.newDirectoryStream(path)) { for (Path subPath : stream) { if (subPath.toFile().isDirectory()) { getAllFiles(fileNames, subPath); } else { String fileName = subPath.toAbsolutePath().toString(); //getLogger().info(String.format("File type: %s - %s", getFileType(fileName), fileName)); fileNames.add(fileName); } } } catch (IOException e) { throw e; } return fileNames; } }