Here you can find the source of getAllFilesInDirectory(String directoryPath)
public static List<String> getAllFilesInDirectory(String directoryPath) throws FileNotFoundException
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.FileFilter; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.List; public class Main { public static List<String> getAllFilesInDirectory(String directoryPath) throws FileNotFoundException { return getAllFilesInDirectory(directoryPath, null); }//from w ww .j a v a 2 s. c o m public static List<String> getAllFilesInDirectory(String directoryPath, FileFilter filter) throws FileNotFoundException { List<String> filesList = new ArrayList<>(); File directory = new File(directoryPath); File[] fileObjList; if (filter != null) { fileObjList = directory.listFiles(filter); } else { fileObjList = directory.listFiles(); } if (fileObjList == null) { throw new FileNotFoundException(directoryPath + " does not exist."); } for (File file : fileObjList) { if (file.isFile()) { filesList.add(file.getAbsolutePath()); } } return filesList; } }