List of utility methods to do Folder File List
File[] | ListFiles(File dir, FilenameFilter filter) Lists the files in a specific directory that satisfy the filter. File[] files = null; if (dir != null && dir.isDirectory()) { files = dir.listFiles(filter); return files; |
List | getAllFilesAndFolders(File root, boolean containEmpty) Get all files and directories under the specified fold. Assert.assertFileExist(root); List<File> files = new ArrayList<File>(); if (containEmpty || (!containEmpty && !isEmpty(root))) { files.add(root); if (root.isDirectory()) { File[] fs = root.listFiles(); for (File f : fs) { ... |
String[] | getFileNames(String dirPath) get File Names return getFileNames(dirPath, null);
|
String[] | getFileNames(String dirPath, FilenameFilter fileNameFilter) get File Names String fileNames[] = null; File dir = new File(dirPath); if (dir.isDirectory()) { if (fileNameFilter != null) { fileNames = dir.list(fileNameFilter); } else { fileNames = dir.list(); return fileNames; |
void | getFiles(File dir, List outList) Recursively get the list of the files in a given dir and add it to the list passed in the second argument. if (dir == null) { return; try { if (!dir.isDirectory()) { return; File[] list = dir.listFiles(); ... |
String[] | listFiles(String fileName) list Files return listFiles(new File(fileName)); |
boolean | pathContains(String root, String child) Verifies that a path, child, is inside of a parent path root Path childPath = Paths.get(Files.simplifyPath(child));
Path rootPath = Paths.get(root);
return childPath.startsWith(rootPath);
|
List | listFile(File file) list File if (file.isDirectory()) { File[] files = file.listFiles(); for (File f : files) { listFile(f); } else { fileNames.add(file.getAbsolutePath()); return fileNames; |
String[] | listFiles(File file) list Files List files = new ArrayList(); File[] fileArray = file.listFiles(); for (int i = 0; i < fileArray.length; i++) { if (fileArray[i].isFile()) { files.add(fileArray[i].getName()); return (String[]) files.toArray(new String[0]); ... |
List | getFileList(File f) get File List List<File> list = new ArrayList<File>(); for (File tmp : f.listFiles()) { list.add(tmp); return list; |