Here you can find the source of getAllFiles(File directory)
private static List<File> getAllFiles(File directory)
//package com.java2s; //License from project: Apache License import java.io.File; import java.util.ArrayList; import java.util.List; public class Main { private static List<File> getAllFiles(File directory) { List<File> fileList = new ArrayList<File>(); File[] files = directory.listFiles(); if (files != null) { for (File file : files) { fileList.add(file);/*from ww w .j a va2s . c o m*/ if (file.isDirectory()) { fileList.addAll(getAllFiles(file)); } } } return fileList; } }