Here you can find the source of getFilesAndSubFolderFiles(List
public static void getFilesAndSubFolderFiles(List<File> fileList, File rootDir)
//package com.java2s; import java.io.File; import java.util.List; public class Main { public static void getFilesAndSubFolderFiles(List<File> fileList, File rootDir) {// w w w .j a v a 2 s . c o m if (fileList != null) { File[] files = rootDir.listFiles(); if (files != null) { for (File file : files) { if (file.isFile()) { fileList.add(file); } else if (file.isDirectory()) { getFilesAndSubFolderFiles(fileList, file); } } } } } }