List of usage examples for java.io FilenameFilter FilenameFilter
FilenameFilter
From source file:com.dattack.dbping.cli.PingAnalyzerCli.java
private void execute(final File file, final ReportContext context) throws ConfigurationException { if (file.isDirectory()) { final FilenameFilter filter = new FilenameFilter() { @Override//from w w w .jav a 2 s. c o m public boolean accept(final File dir, final String name) { return name.toLowerCase().endsWith(".log"); } }; execute(file.listFiles(filter), context); } else { try { Reporter.execute(file, context); } catch (final IOException e) { e.printStackTrace(); } } }
From source file:com.dragome.compiler.writer.Assembly.java
private void removeOldAssemblies(File assembly) { final String numericPostfixPattern = "-[0-9]*$"; final String prefix = assembly.getName().replaceAll(numericPostfixPattern, ""); File[] oldAssemblies = assembly.getParentFile().listFiles(new FilenameFilter() { public boolean accept(File dir1, String name) { return name.matches(prefix + numericPostfixPattern); }/*from ww w .j a v a2 s . c om*/ }); if (oldAssemblies == null) { return; } for (File oldAssemblyDir : oldAssemblies) { for (File file : oldAssemblyDir.listFiles()) { file.delete(); } oldAssemblyDir.delete(); } }
From source file:edu.unc.lib.dl.services.BatchIngestQueue.java
/** * @return//from w ww . ja v a2s . c o m */ public File[] getReadyIngestDirectories() { File[] batchDirs = this.queuedDirectory.listFiles(new FileFilter() { @Override public boolean accept(File arg0) { if (arg0.isDirectory()) { String[] readyFiles = arg0.list(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return (READY_FILE.equals(name)); } }); if (readyFiles != null && readyFiles.length > 0) { return true; } } return false; } }); if (batchDirs != null) { Arrays.sort(batchDirs, new Comparator<File>() { @Override public int compare(File o1, File o2) { if (o1 == null || o2 == null) return 0; return (int) (o1.lastModified() - o2.lastModified()); } }); return batchDirs; } else { return new File[] {}; } }
From source file:net.kayateia.lifestream.WatchedPaths.java
public File[] checkPath(File f) { // Get the absolute path, and make sure it's on the SD card. String absPath = f.getAbsolutePath(); String sdPath = Environment.getExternalStorageDirectory().getAbsolutePath(); if (!absPath.startsWith(sdPath)) return null; // Okay. Check it against our path prefixes. String pathPart = f.getParent().substring(sdPath.length()); Path match = null;//from w w w . jav a2 s . co m for (Path p : _paths) { if (p.path.equals(pathPart)) { match = p; break; } } if (match == null) return null; // Check wildcards if specified. if (!match.fileWildcard.equals("")) { String filePart = f.getName(); String regex = "^" + match.fileWildcard.replace(".", "\\.").replace("*", ".*") + "$"; if (!filePart.matches(regex)) return null; } // Finally, look for extra files if needed. if (!match.extraWildcard.equals("")) { final String regex = "^" + match.extraWildcard.replace(".", "\\.").replace("*", ".*") + "$"; return f.getParentFile().listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return name.matches(regex); } }); } else return new File[0]; }
From source file:com.stormcloud.ide.api.ServicesController.java
@RequestMapping(method = RequestMethod.GET, produces = "application/json") @ResponseBody//w ww . ja va 2 s . com public Services[] getServices() throws TomcatManagerException { Services[] response = new Services[1]; // create root node Services services = new Services(); // create databases //Item databases = new Item(); //databases.setLabel("Databases"); //databases.setType(ItemType.NONE); //databases.setStyle("rdbms"); /** * @todo change this into rdbmsManager who will fetch database info like * tomcatManager does */ //Item javaDb = new Item(); //javaDb.setLabel("Java DB"); //javaDb.setType("javadb"); //databases.getChildren().add(javaDb); //Item mysql = new Item(); //mysql.setLabel("MySQL"); //mysql.setType("mysql"); //databases.getChildren().add(mysql); //Item oracle = new Item(); //oracle.setLabel("Oracle"); //oracle.setType("oracle"); //databases.getChildren().add(oracle); // add databases to services //services.getChildren().add(databases); // Web Services //Item webservices = new Item(); //webservices.setLabel("Web Services"); //webservices.setType("webServices"); /** * @todo add some example webservices */ // add webservices to services //services.getChildren().add(webservices); // create servers group Item servers = new Item(); servers.setLabel("Servers"); servers.setType(ItemType.NONE); servers.setStyle("servers"); /** * @todo add glassfish, jboss, weblogic */ // add tomcat servers.getChildren().add(tomcatManager.getTomcat()); // add servers to services services.getChildren().add(servers); // Maven Repositories Item mavenRepos = new Item(); mavenRepos.setLabel("Maven Repositories"); mavenRepos.setType(ItemType.NONE); mavenRepos.setStyle("mavenRepositories"); // add local repo Item local = new Item(); local.setLabel("Local"); local.setType(ItemType.NONE); local.setStyle("localMavenRepository"); File m2 = new File(RemoteUser.get().getSetting(UserSettings.LOCAL_MAVEN_REPOSITORY)); FilenameFilter filter = new FilenameFilter() { @Override public boolean accept(File file, String string) { if (string.startsWith("_")) { return false; } if (string.endsWith(".lastUpdated")) { return false; } return true; } }; walk(local, m2, filter); mavenRepos.getChildren().add(local); // add maven repositories services.getChildren().add(mavenRepos); // Continuous Integration //Item ci = new Item(); //ci.setLabel("Continuous Integration"); //ci.setType("continuousIntegration"); // add ci to services //services.getChildren().add(ci); // Issue Trackers //Item issueTrackers = new Item(); //issueTrackers.setLabel("Issue Trackers"); //issueTrackers.setType("issueTrackers"); // add issue trackers to services //services.getChildren().add(issueTrackers); response[0] = services; return response; }
From source file:marytts.util.io.FileUtils.java
/** * List the basenames of all files in directory that end in suffix, without that suffix. * For example, if suffix is ".wav", return the names of all .wav files in the * directory, but without the .wav extension. The file names * are sorted in alphabetical order, according to java's string search. * @param directory/* w w w . j a v a 2 s . co m*/ * @param suffix * @return */ public static String[] listBasenames(File directory, String suffix) { final String theSuffix = suffix; String[] filenames = directory.list(new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith(theSuffix); } }); /* Sort the file names alphabetically */ Arrays.sort(filenames); for (int i = 0; i < filenames.length; i++) { filenames[i] = filenames[i].substring(0, filenames[i].length() - suffix.length()); } return filenames; }
From source file:infowall.domain.service.DashboardImporter.java
private List<File> listJsonFiles() { File dashboardDir = findDashboardBaseDir(); if (!dashboardDir.exists()) { logger.warn("Dashboard config dir does not exist, no dashboards will be imported."); return Collections.emptyList(); }/* w w w . j av a 2 s .c o m*/ return asList(dashboardDir.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.endsWith(JSON); } })); }
From source file:fll.web.GatherBugReport.java
/** * Add the web application and tomcat logs to the zipfile. */// w ww . ja va 2 s. c o m private static void addLogFiles(final ZipOutputStream zipOut, final ServletContext application) throws IOException { // get logs from the webapp final File fllAppDir = new File(application.getRealPath("/")); final File[] webLogs = fllAppDir.listFiles(new FilenameFilter() { @Override public boolean accept(final File dir, final String name) { return name.startsWith("fllweb.log"); } }); if (null != webLogs) { for (final File f : webLogs) { if (f.isFile()) { FileInputStream fis = null; try { zipOut.putNextEntry(new ZipEntry(f.getName())); fis = new FileInputStream(f); IOUtils.copy(fis, zipOut); fis.close(); } finally { IOUtils.closeQuietly(fis); } } } } // get tomcat logs final File webappsDir = fllAppDir.getParentFile(); LOGGER.trace("Webapps dir: " + webappsDir.getAbsolutePath()); final File tomcatDir = webappsDir.getParentFile(); LOGGER.trace("Tomcat dir: " + tomcatDir.getAbsolutePath()); final File tomcatLogDir = new File(tomcatDir, "logs"); LOGGER.trace("tomcat log dir: " + tomcatLogDir.getAbsolutePath()); final File[] tomcatLogs = tomcatLogDir.listFiles(); if (null != tomcatLogs) { for (final File f : tomcatLogs) { if (f.isFile()) { FileInputStream fis = null; try { zipOut.putNextEntry(new ZipEntry(f.getName())); fis = new FileInputStream(f); IOUtils.copy(fis, zipOut); fis.close(); } finally { IOUtils.closeQuietly(fis); } } } } }
From source file:ee.ria.DigiDoc.util.FileUtils.java
public static List<File> getContainers(Context context) { FilenameFilter containersOnly = new FilenameFilter() { @Override//from w ww . ja v a 2 s. co m public boolean accept(File dir, String name) { String lowerName = name.toLowerCase(); return lowerName.endsWith(".bdoc") || lowerName.endsWith(".ddoc") || lowerName.endsWith(".asice") || lowerName.endsWith(".sce") || lowerName.endsWith(".scs") || lowerName.endsWith(".edoc") || lowerName.endsWith(".adoc") || lowerName.endsWith(".asics"); } }; File[] containerFilesInBaseDir = baseStorageDir.listFiles(containersOnly); File[] containerFilesInDigiDocDir = FileUtils.getContainersDirectory(context).listFiles(containersOnly); if (containerFilesInBaseDir == null && containerFilesInDigiDocDir == null) { return Collections.emptyList(); } List<File> containers = new ArrayList<>(); if (containerFilesInBaseDir != null) { Collections.addAll(containers, containerFilesInBaseDir); } if (containerFilesInDigiDocDir != null) { Collections.addAll(containers, containerFilesInDigiDocDir); } return containers; }
From source file:com.application.error.ExceptionHandler.java
/** * Search for stack trace files./* w w w. j ava 2 s . co m*/ * @return */ private static String[] searchForStackTraces() { if (stackTraceFileList != null) { return stackTraceFileList; } File dir = new File(G.FILES_PATH + "/"); // Try to create the files folder if it doesn't exist dir.mkdir(); // Filter for ".stacktrace" files FilenameFilter filter = new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.endsWith(".stacktrace"); } }; return (stackTraceFileList = dir.list(filter)); }