Here you can find the source of getFilesFromFolder(String folderPath, ArrayList
public static void getFilesFromFolder(String folderPath, ArrayList<File> files)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.util.ArrayList; public class Main { public static void getFilesFromFolder(String folderPath, ArrayList<File> files) { File folder = new File(folderPath); File[] fList = folder.listFiles(); if (fList != null) { for (File file : fList) { if (file.isFile()) { files.add(file);//from w w w . j ava2s .c o m } else if (file.isDirectory()) { getFilesFromFolder(file.getAbsolutePath(), files); } } } } }