Here you can find the source of getAllFilesInDirectory(String dirName)
public static List<File> getAllFilesInDirectory(String dirName)
//package com.java2s; //License from project: Apache License import java.io.File; import java.util.ArrayList; import java.util.List; public class Main { public static List<File> getAllFilesInDirectory(String dirName) { File folder = new File(dirName); File[] listOfFiles = folder.listFiles(); List<File> result = new ArrayList<>(); for (int i = 0; i < listOfFiles.length; i++) { if (listOfFiles[i].isFile()) { result.add(listOfFiles[i]); }/* ww w . j a va 2 s .co m*/ } return result; } }