List of usage examples for java.io FilenameFilter FilenameFilter
FilenameFilter
From source file:com.hybris.mobile.logging.ExceptionHandler.java
private static String[] searchForStackTraces() { if (stackTraceFileList != null) { return stackTraceFileList; }/*from w ww . ja v a 2 s . c om*/ File dir = new File(RA.FILES_PATH + "/"); dir.mkdir(); FilenameFilter filter = new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith(".stacktrace"); } }; return (stackTraceFileList = dir.list(filter)); }
From source file:com.linkedin.pinot.tools.admin.command.StopProcessCommand.java
@Override public boolean execute() throws Exception { LOGGER.info("Executing command: " + toString()); Map<String, String> processes = new HashMap<String, String>(); String prefix = System.getProperty("java.io.tmpdir") + File.separator; File tempDir = new File(System.getProperty("java.io.tmpdir")); if (_server) { File[] serverFiles = tempDir.listFiles(new FilenameFilter() { @Override//w ww . j a va 2s . c o m public boolean accept(File dir, String name) { if (StringUtils.containsIgnoreCase(name, "pinotAdminServer")) { return true; } return false; } }); for (File serverFile : serverFiles) { processes.put(serverFile.getName(), serverFile.getAbsolutePath()); } } if (_broker) { File[] serverFiles = tempDir.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { if (StringUtils.containsIgnoreCase(name, "pinotAdminBroker")) { return true; } return false; } }); for (File serverFile : serverFiles) { processes.put(serverFile.getName(), serverFile.getAbsolutePath()); } } if (_controller) { File[] serverFiles = tempDir.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { if (StringUtils.containsIgnoreCase(name, "pinotAdminController")) { return true; } return false; } }); for (File serverFile : serverFiles) { processes.put(serverFile.getName(), serverFile.getAbsolutePath()); } } if (_zooKeeper) { processes.put("Zookeeper", prefix + ".zooKeeper.pid"); } if (_kafka) { processes.put("Kafka", prefix + ".kafka.pid"); } boolean ret = true; for (Map.Entry<String, String> entry : processes.entrySet()) { try { stopProcess(entry.getValue()); } catch (Exception e) { System.out.println("Failed to stop process: " + entry.getKey() + ": " + e); ret = false; } } return ret; }
From source file:net.geoprism.data.LocalEndpoint.java
private List<String> listFiles(String prefix) { LinkedList<String> paths = new LinkedList<String>(); FilenameFilter filter = new FilenameFilter() { @Override/*from www .java 2 s . c o m*/ public boolean accept(File dir, String name) { return name.endsWith(".xml.gz"); } }; File directory = new File(this.root, prefix); File[] files = directory.listFiles(filter); if (files != null) { for (File file : files) { paths.add(this.root.toURI().relativize(file.toURI()).getPath()); } } return paths; }
From source file:org.pentaho.pat.server.util.JdbcDriverFinder.java
private void scan(final long timeMil) { final FilenameFilter libs = new FilenameFilter() { public boolean accept(final File dir, final String pathname) { return pathname.endsWith("jar") || pathname.endsWith("zip"); //$NON-NLS-1$//$NON-NLS-2$ }//w w w .j a v a 2 s. com }; final ResolverUtil<Driver> resolver = new ResolverUtil<Driver>(); for (File directory : this.jdbcDriverDirectory) { for (File lib : directory.listFiles(libs)) { try { resolver.loadImplementationsInJar("", lib.toURI().toURL(), //$NON-NLS-1$ new ResolverUtil.IsA(Driver.class)); } catch (MalformedURLException e) { LOG.trace(e); continue; } } } List<String> drivers = new ArrayList<String>(); for (Class<? extends Driver> cd : resolver.getClasses()) { drivers.add(cd.getName()); } this.lastCall = timeMil; this.drivers = drivers; }
From source file:net.solarnetwork.node.backup.FileBackupResourceProvider.java
@Override public Iterable<BackupResource> getBackupResources() { if (resourceDirectories == null || resourceDirectories.length < 1) { return Collections.emptyList(); }//from w w w. ja va 2 s .c om final Pattern pat = (fileNamePattern == null ? null : Pattern.compile(fileNamePattern, Pattern.CASE_INSENSITIVE)); List<BackupResource> fileList = new ArrayList<BackupResource>(20); for (String path : resourceDirectories) { File rootDir = (rootPath != null && rootPath.length() > 0 ? new File(rootPath, path) : new File(path)); if (!rootDir.isDirectory()) { log.info("Skipping path {} because does not exist or is not a directory", rootDir.getAbsolutePath()); continue; } File[] files = rootDir.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return pat.matcher(name).find(); } }); if (files == null || files.length < 1) { continue; } for (File f : files) { // make sure backup path is relative final String backupPath = path + '/' + f.getName(); String digest = null; InputStream in = null; try { in = new BufferedInputStream(new FileInputStream(f)); digest = DigestUtils.sha256Hex(in); } catch (IOException e) { log.warn("Error calculating SHA-256 digest of {}: {}", f, e.getMessage()); } finally { if (in != null) { try { in.close(); } catch (IOException e) { // ignore } } } fileList.add(new ResourceBackupResource(new FileSystemResource(f), backupPath, getKey(), digest)); } } return fileList; }
From source file:com.ccoe.build.core.utils.FileUtils.java
public static File[] loadFiles(final File targetFolder, final String ext) { return targetFolder.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return name.toLowerCase().endsWith(ext); }// w ww . j a v a2 s . c o m }); }
From source file:it.geosolutions.geofence.gui.server.utility.IoUtility.java
/** * Gets the shp file.//from ww w . j av a 2 s .c o m * * @param tmpDestDir * the tmp dest dir * @return the shp file */ private static File getShpFile(File tmpDestDir) { File[] files = tmpDestDir.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return FilenameUtils.getExtension(name).equalsIgnoreCase("shp"); } }); return (files.length > 0) ? files[0] : null; }
From source file:com.rukiasoft.androidapps.comunioelpuntal.crashlogs.ExceptionHandler.java
public static String[] searchForStackTraces() { if (stackTraceFileList != null) { return stackTraceFileList; }//from w ww . j a va 2s . co m 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() { public boolean accept(File dir, String name) { return name.endsWith(".stacktrace"); } }; return (stackTraceFileList = dir.list(filter)); }
From source file:interactivespaces.launcher.bootstrap.FileConfigurationProvider.java
/** * Load all conf files in the configuration folder. */// w w w . j a v a2s.co m public void load() { currentConfiguration = new HashMap<String, String>(); // Calculate the proper home directory for this install of interactive spaces. String isHomeEnvPath = System.getenv(INTERACTIVESPACES_HOME_ENVIRONMENT_KEY); File isHomeDir = isHomeEnvPath != null ? new File(isHomeEnvPath) : new File(baseInstallFolder, INTERACTIVESPACES_HOME_DEFAULT_DIR); currentConfiguration.put(CoreConfiguration.CONFIGURATION_INTERACTIVESPACES_HOME, isHomeDir.getAbsolutePath()); // Look in the specified bundle directory to create a list // of all JAR files to install. File[] files = configFolder.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.toLowerCase().endsWith(CONFIGURATION_FILES_EXTENSION); } }); if (files == null || files.length == 0) { log.error(String.format("Couldn't load config files from %s\n", configFolder.getAbsolutePath())); } for (File file : files) { Properties props = new Properties(); try { props.load(new FileInputStream(file)); for (Entry<Object, Object> p : props.entrySet()) { currentConfiguration.put((String) p.getKey(), (String) p.getValue()); } } catch (IOException e) { log.error(String.format("Couldn't load config file %s\n", file)); } } }
From source file:de.julielab.jcore.reader.file.main.FileReader.java
/** * @see org.apache.uima.collection.CollectionReader_ImplBase#initialize() */// w w w . j a v a 2 s .c o m @Override public void initialize() throws ResourceInitializationException { File inputDirectory = new File(((String) getConfigParameterValue(DIRECTORY_INPUT)).trim()); if (getConfigParameterValue(PUBLICATION_DATES_FILE) != null) { publicationDatesFile = new File(((String) getConfigParameterValue(PUBLICATION_DATES_FILE)).trim()); } Boolean filenameAsDocId = (Boolean) getConfigParameterValue(FILENAME_AS_DOC_ID); if (null == filenameAsDocId) { useFilenameAsDocId = false; } else { useFilenameAsDocId = filenameAsDocId; } String[] allowedExtensionsArray = (String[]) getConfigParameterValue(ALLOWED_FILE_EXTENSIONS); final Set<String> allowedExtensions = new HashSet<>(); if (null != allowedExtensionsArray) { for (int i = 0; i < allowedExtensionsArray.length; i++) { String allowedExtension = allowedExtensionsArray[i]; allowedExtensions.add(allowedExtension); } } fileIndex = 0; if (!inputDirectory.exists() || !inputDirectory.isDirectory()) { throw new ResourceInitializationException(ResourceConfigurationException.DIRECTORY_NOT_FOUND, new Object[] { DIRECTORY_INPUT, this.getMetaData().getName(), inputDirectory.getPath() }); } files = new ArrayList<File>(); File[] f = inputDirectory.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { if (allowedExtensions.isEmpty()) return true; String extension = name.substring(name.lastIndexOf('.') + 1); return allowedExtensions.contains(extension); } }); for (int i = 0; i < f.length; i++) { if (!f[i].isDirectory()) { files.add(f[i]); } } }