Here you can find the source of getFileList(File dir, Set
Parameter | Description |
---|---|
dir | the dir |
arrayList | the array list |
public static boolean getFileList(File dir, Set<File> arrayList)
//package com.java2s; //License from project: Apache License import java.io.*; import java.util.HashSet; import java.util.Set; public class Main { /**/*from w w w. j av a 2s . c o m*/ * Gets file list. * * @param dir the dir * @param arrayList the array list * @return the file list */ public static boolean getFileList(File dir, Set<File> arrayList) { return getFileList(dir, null, arrayList); } /** * Gets file list. * * @param dir the dir * @param filter the filter * @param set the set * @return the file list */ public static boolean getFileList(File dir, FileFilter filter, Set<File> set) { if (dir == null || !dir.exists()) { return false; } if (set == null) { set = new HashSet<File>(); } if (dir.isFile()) { return true; } File[] files = filter == null ? dir.listFiles() : dir.listFiles(filter); for (File f : files) { set.add(f); if (f.isDirectory()) { getFileList(f, filter, set); continue; } } return true; } }