Here you can find the source of getFiles(File... repertoires)
Parameter | Description |
---|---|
repertoires | directories |
public static File[] getFiles(File... repertoires)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.util.ArrayList; public class Main { /**//from w w w .jav a2 s . c o m *Return all the files (not directories) in the directories "repertoires" recursively. *@param repertoires directories *@return files in directories "repertoires" */ public static File[] getFiles(File... repertoires) { File[] ret = null; ArrayList<File> files = new ArrayList<File>(); for (int i = 0; i < repertoires.length; i++) addDirectoryContents(files, repertoires[i]); ret = new File[files.size()]; for (int i = 0; i < files.size(); i++) ret[i] = files.get(i); return ret; } /** *Add to the ArrayList<File>" files" all files in the directory "dir" recursively. *@param files *@param dir files in this directory will be added to "files" */ private static void addDirectoryContents(ArrayList<File> files, File dir) { File[] files1 = dir.listFiles(); if (files1 != null) { for (int i = 0; i < files1.length; i++) { if (files1[i].isDirectory()) addDirectoryContents(files, files1[i]); else files.add(files1[i]); } } } }