Java tutorial
//package com.java2s; //License from project: Open Source License import java.io.File; import java.util.ArrayList; public class Main { /** * return all the files contained in the specified directory */ public static void fileList(String directoryName, ArrayList<File> files) { File directory = new File(directoryName); // get all the files from a directory File[] fList = directory.listFiles(); for (File file : fList) { if (file.isFile()) { files.add(file); } else if (file.isDirectory()) { fileList(file.getAbsolutePath(), files); } } } }