Here you can find the source of getFilesRealWorking(File aStartingDir, FilenameFilter filter)
static public List<File> getFilesRealWorking(File aStartingDir, FilenameFilter filter)
//package com.java2s; /*/*from w w w .jav a 2 s . c o m*/ * Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * * Initial Contributors: * Nokia Corporation - initial contribution. * * Contributors: * * Description: * */ import java.io.File; import java.io.FilenameFilter; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; public class Main { static public List<File> getFilesRealWorking(File aStartingDir, FilenameFilter filter) { List<File> result = new ArrayList<File>(); File[] filesAndDirs = aStartingDir.listFiles(); List filesDirs = Arrays.asList(filesAndDirs); Iterator filesIter = filesDirs.iterator(); File file = null; while (filesIter.hasNext()) { file = (File) filesIter.next(); if (filter.accept(aStartingDir, file.getName())) { result.add(file); // always add, even if directory } if (!file.isFile()) { List<File> deeperList = getFilesRealWorking(file, filter); result.addAll(deeperList); } } return result; } }