Here you can find the source of getFiles(String sourceName, FilenameFilter filter)
Parameter | Description |
---|---|
sourceName | a parameter |
filter | a parameter |
public static ArrayList getFiles(String sourceName, FilenameFilter filter)
//package com.java2s; /*/* ww w . j a v a 2 s. c o m*/ * Copyright (c) Fiorano Software Pte. Ltd. and affiliates. All rights reserved. http://www.fiorano.com * The software in this package is published under the terms of the CPAL v1.0 * license, a copy of which has been included with this distribution in the * LICENSE.txt file. */ import java.io.*; import java.util.*; public class Main { /** * Get the list of files contained in parent parameter directory * * @param sourceName * @param filter * @return */ public static ArrayList getFiles(String sourceName, FilenameFilter filter) { File sourceFile = new File(sourceName); ArrayList result = new ArrayList(); if (!sourceFile.exists() || !sourceFile.isDirectory()) return result; String[] fileNames = sourceFile.list(filter); if (fileNames == null) return result; for (int i = 0; i < fileNames.length; i++) { File file = new File(fileNames[i]); if (file.isDirectory()) result.addAll(getFiles(fileNames[i], filter)); else result.add(fileNames[i]); } return result; } }