Here you can find the source of getFileInDirectory(File f)
public static List<File> getFileInDirectory(File f)
//package com.java2s; import java.io.File; import java.util.ArrayList; import java.util.List; public class Main { public static List<File> getFileInDirectory(File f) { List<File> list = getFileList(f); boolean check = true; while (check) { check = false;//from w w w .ja v a 2 s.co m List<File> listtmp = list; List<File> listtmp2 = new ArrayList<File>(); ; for (File checktmp : listtmp) { if (checktmp.isFile()) { listtmp2.add(checktmp); } if (checktmp.isDirectory()) { check = true; for (File f2 : getFileList(checktmp)) { listtmp2.add(f2); } } } list = listtmp2; } return list; } public static List<File> getFileList(File f) { List<File> list = new ArrayList<File>(); for (File tmp : f.listFiles()) { list.add(tmp); } return list; } }