Here you can find the source of getAllFilesInDir(boolean traverseSubDirs, File dir, boolean includeHidden, String prefix)
private static List<String> getAllFilesInDir(boolean traverseSubDirs, File dir, boolean includeHidden, String prefix)
//package com.java2s; /* MonkeyTalk - a cross-platform functional testing tool Copyright (C) 2012 Gorilla Logic, Inc.//from www. ja v a 2 s. co m This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ import java.io.File; import java.util.ArrayList; import java.util.List; public class Main { private static List<String> getAllFilesInDir(boolean traverseSubDirs, File dir, boolean includeHidden, String prefix) { List<String> files = new ArrayList<String>(); String fileNames[] = dir.list(); for (String fileName : fileNames) { File currentFile = new File(dir, fileName); if (currentFile.isHidden() && !includeHidden) { continue; } if (currentFile.isDirectory()) { if (traverseSubDirs) { String pfx; if (prefix == null || prefix.length() == 0) { pfx = fileName; } else { pfx = prefix + "/" + fileName; } files.addAll(getAllFilesInDir(true, currentFile, includeHidden, pfx)); } } else { String fullname = fileName; if (prefix != null && prefix.length() > 0) { fullname = prefix + "/" + fileName; } files.add(fullname); } } return files; } }