private static void internalBuildFileList(List<String> lst, File rootDir, boolean recursive) { // read all files in current directory, recurse into subdirs // append files to supplied list File flist[] = null; try { flist = rootDir.listFiles(); } catch (Exception e) { // don't care what exception is there. // by contract, only a SecurityException is possible, but who // knows... } // if IOException occured, flist is null // and we simply return if (flist == null) return; for (File file : flist) { if (file.isDirectory()) { continue; // recurse into directories later } lst.add(file.getAbsolutePath()); } if (recursive) { for (File file : flist) { if (isProperDirectory(file)) // Ignores some directories { // now recurse into subdirectories buildFileList(lst, file, true); } } } }