List of usage examples for java.io File listFiles
public File[] listFiles(FileFilter filter)
From source file:cc.kave.commons.externalserializationtests.ExternalTestCaseProvider.java
private static File[] getSubdirectories(File currentDirectory) { return currentDirectory.listFiles(new FilenameFilter() { @Override//from w w w . jav a 2 s . com public boolean accept(File current, String name) { return new File(current, name).isDirectory(); } }); }
From source file:Main.java
public static File[] listFiles(File directory, boolean recurse, FileFilter filter) { if (!recurse) { return directory.listFiles(filter); } else {//from w w w . j a v a 2 s . co m Collection<File> mFiles = new java.util.LinkedList<>(); innerListFiles(mFiles, directory, filter); return mFiles.toArray(new File[mFiles.size()]); } }
From source file:Main.java
public static File[] listFiles(File directory, boolean recurse, FileFilter filter) { if (!recurse) { return directory.listFiles(filter); } else {//from w ww .j a va 2 s .c om Collection<File> mFiles = new java.util.LinkedList<File>(); innerListFiles(mFiles, directory, filter); return (File[]) mFiles.toArray(new File[mFiles.size()]); } }
From source file:com.codename1.tools.javadoc.sourceembed.javadocsourceembed.Main.java
public static void directoryWalker(File f, File destDir) throws Exception { File[] files = f.listFiles((path) -> path.isDirectory() || path.getName().endsWith(".java")); for (File ff : files) { if (ff.isDirectory()) { File destDirT = new File(destDir, ff.getName()); destDirT.mkdirs();//from w ww. j a v a2 s . c o m directoryWalker(ff, destDirT); } else { processFile(ff, new File(destDir, ff.getName())); } } }
From source file:Main.java
/** * Compress files to a zip, and includes other operations such as filter,clean files * //from w w w .j a v a 2 s .co m * @param zip * @param directory * @param filter * @throws IOException */ public static void compress(String zip, String directory, FilenameFilter filter) throws IOException { File fzip = new File(zip); File fdir = new File(directory); File files[] = fdir.listFiles(filter); if (files.length <= 0) { cleanZip(fzip); return; } else { compressToZip(fzip, files); cleanFiles(files); } }
From source file:com.hp.test.framework.jmeterTests.GetJmeterTestCaseFileList.java
public static List getjmeterTestcaseList() { List<String> jmeterFileList; jmeterFileList = new ArrayList<String>(); ReadJmeterConfigProps readjmeterconfigprops = new ReadJmeterConfigProps(); String path = readjmeterconfigprops.getProperty("location.java.files"); File dir = new File(path); FileFilter fileFilter = new WildcardFileFilter("*.java"); File[] files = dir.listFiles(fileFilter); for (File file : files) { jmeterFileList.add(file.getName()); }/* ww w .j av a 2 s . co m*/ return jmeterFileList; }
From source file:com.starit.diamond.utils.AppNameUtils.java
private static File[] listFiles(File dir, final String suffix, final String[] excludes) { return dir.listFiles(new FileFilter() { public boolean accept(File file) { return !inExcludes(file, excludes) && file.getName().toLowerCase().endsWith(suffix); }/*from w w w . j av a 2 s .c o m*/ }); }
From source file:muffinc.yafdivj.helper.FeretHandler.java
public static void rename(String s) { for (File file : new File(s).listFiles()) { if (file.isDirectory()) { int size = file.listFiles(((FileFilter) new WildcardFileFilter("*.tif"))).length; file.renameTo(new File(file.getParent() + "/" + file.getName() + "_" + size)); }// ww w . ja v a2 s .c o m } }
From source file:me.doshou.admin.maintain.editor.web.controller.utils.OnlineEditorUtils.java
public static boolean hasSubFiles(File file) { File[] subFiles = file.listFiles(DIRECTORY_FILTER); return subFiles != null && subFiles.length > 0; }
From source file:Main.java
static String composeFilesString(final String dirPath, final List<String> subDirPaths, final String pattern, int skip) { final StringBuilder sb = new StringBuilder(); final List<File> allFiles = new ArrayList<>(); final FilenameFilter filter = new FilenameFilter() { @Override/*from w w w. jav a2 s. com*/ public boolean accept(File dir, String name) { return name.matches(pattern); } }; for (final String subDirPath : subDirPaths) { final File subDir = new File(dirPath, subDirPath); final File[] files = subDir.listFiles(filter); if (files == null) { throw new RuntimeException(String.format("%s directory does not exist", subDir.getPath())); } Arrays.sort(files); Collections.addAll(allFiles, files); } final int m; final int n; if (skip >= 0) { m = skip; n = allFiles.size(); } else { m = 0; n = allFiles.size() + skip; } for (int i = m; i < n; i++) { final File file = allFiles.get(i); if (sb.length() > 0) { sb.append(' '); } sb.append(file.getPath()); } return sb.toString(); }