Here you can find the source of getAllFiles(File directory, boolean hidden)
public static File[] getAllFiles(File directory, boolean hidden)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.util.ArrayList; import java.util.List; public class Main { public static File[] getAllFiles(File directory, boolean hidden) { File[] files = directory.listFiles(); List<File> fileLst = new ArrayList<File>(); for (File file : files) { File[] fs = getFile(file, hidden); for (File f : fs) { fileLst.add(f);/*from w ww . j ava 2s .c o m*/ } } return fileLst.toArray(new File[fileLst.size()]); } public static File[] getFile(String path, boolean hidden) { return getFile(new File(path), hidden); } public static File[] getFile(File directory, boolean hidden) { if (!directory.exists()) { return null; } else if (!hidden && directory.isHidden()) { return new File[] {}; } else if (directory.isFile()) { return new File[] { directory }; } else if (directory.isDirectory()) { return getAllFiles(directory, hidden); } return null; } }