Here you can find the source of getFilesForFolder(File folder)
public static ArrayList<File> getFilesForFolder(File folder)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.util.ArrayList; public class Main { public static ArrayList<File> getFilesForFolder(File folder) { ArrayList<File> files = new ArrayList<File>(); for (File file : folder.listFiles()) { if (file.isDirectory()) { ArrayList<File> childFolderFiles = new ArrayList<File>(); childFolderFiles = getFilesForFolder(file); files.addAll(childFolderFiles); } else { files.add(file);//from ww w . j ava 2 s . c om } } return files; } }