List of utility methods to do Folder Read by Extension
File[] | getFiles(String path, String _exts) get Files File dir = new File(path); final String[] exts = _exts.split(";"); for (int i = 0; i < exts.length; i++) { exts[i] = exts[i].toLowerCase(); return dir.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { ... |
List | getFiles(String path, String[] allowedExtension) get Files List<File> r = new ArrayList<File>(); File rfolder = new File(path); if (rfolder.exists() && rfolder.isDirectory()) { File[] files = rfolder.listFiles(); for (File f : files) { if (isAllowedExtension(f.getName(), allowedExtension)) { r.add(f); return r; |
List | getFiles2List(String path, String[] allowedExtension) get Files List List<String> r = new ArrayList<String>(); File rfolder = new File(path); if (rfolder.exists() && rfolder.isDirectory()) { File[] files = rfolder.listFiles(); for (File f : files) { if (isAllowedExtension(f.getName(), allowedExtension)) { r.add(f.getName()); return r; |
List | getFilesFiteredByExtension(final File parent, final List get Files Fitered By Extension final List<File> res = new ArrayList<File>(); if (!parent.isDirectory()) { return res; for (final File file : parent.listFiles()) { if (matchByExtension(file, extensions)) { res.add(file); return res; |
File[] | getFilesForType(final File target, final String extension) get Files For Type File[] files = target.listFiles(new FileFilter() { public boolean accept(File pathname) { if (pathname.getName().indexOf(extension) != -1) { return true; return false; }); ... |
String[] | getFilesFromExtension(String directory, String[] extensions) Given a directory and an array of extensions return an array of compliant files. List<String> files = new ArrayList<String>(); File currentDir = new File(directory); String[] unknownFiles = currentDir.list(); if (unknownFiles == null) { return new String[0]; for (String unknownFile : unknownFiles) { String currentFileName = directory + System.getProperty("file.separator") + unknownFile; ... |
File[] | getFilesWithExtension(File aDirectory, final String aExtension) Returns a list of files from a directory ending with a specific extension. return aDirectory.listFiles(new FileFilter() { public boolean accept(File lFile) { if (lFile.getName().endsWith(aExtension)) { return true; return false; }); ... |
File[] | getFilesWithExtension(File dir, String extension) get Files With Extension List<File> fileList = new ArrayList<File>(); for (File file : dir.listFiles()) { if (file.getName().toLowerCase().endsWith("." + extension)) fileList.add(file); File[] fileListA = (File[]) fileList.toArray(new File[fileList.size()]); return fileListA; |
String[] | getFilesWithExtension(String directory, String extension) get an array of all files in the given directory, with given extension Vector<String> vector = new Vector<String>(); File f = new File(directory); File[] files = f.listFiles(); for (int i = 0; i < files.length; i++) { if (files[i].getName().endsWith(extension)) { vector.add(files[i].getName()); String[] toReturn = new String[vector.size()]; vector.toArray(toReturn); return toReturn; |
List | getFilesWithinPath(File path, String fileExtension) Returns all the files within the parent directory (including sub-dirs) that have the supplied extension. List<File> result = new ArrayList<File>(); if (!path.isDirectory()) { if (fileExtension == null || fileExtension.equalsIgnoreCase(getFileExtension(path))) result.add(path); return result; addChildFilesToList(path, result, fileExtension); return result; ... |