List of usage examples for java.io FilenameFilter FilenameFilter
FilenameFilter
From source file:com.fusesource.forge.jmstest.executor.BenchmarkValueRecorder.java
synchronized private void recordStats(ReportStatsCommand stats) { SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); OutputStream os = null;//from w w w .j av a 2 s . com ObjectOutputStream oos = null; try { log().debug("stats recieved before writing " + stats.getValues()); final String dateString = sdf.format(new Date()); File targetDir = getBenchmarkWorkDirectory(stats.getClientId().getBenchmarkId()); String[] fileNames = targetDir.list(new FilenameFilter() { public boolean accept(File dir, String name) { return name.startsWith(dateString); } }); File rawData = new File(getBenchmarkWorkDirectory(stats.getClientId().getBenchmarkId()), sdf.format(new Date()) + "-" + fileNames.length + ".raw"); System.err.println("Creating raw file -> " + rawData.getAbsolutePath()); log().debug("Writing benchmark raw data to : " + rawData.getAbsolutePath()); os = new FileOutputStream(rawData, false); oos = new ObjectOutputStream(os); oos.writeObject(stats); } catch (Exception e) { log().debug("Error Writing benchmark raw data."); } finally { if (oos != null) { try { oos.close(); } catch (IOException e) { // ignore } } } }
From source file:ddf.catalog.cache.impl.FileSystemPersistenceProvider.java
private FilenameFilter getFilenameFilter() { FilenameFilter filter = new FilenameFilter() { @Override/*from w ww . j a v a 2 s . com*/ public boolean accept(File file, String name) { return name.toLowerCase().endsWith(SER); } }; return filter; }
From source file:com.evolveum.midpoint.testing.model.client.sample.Upload.java
private static void uploadDir(String dirname, CommandLine cmdline, ModelPortType modelPort) { File[] files = new File(dirname).listFiles(new FilenameFilter() { @Override/* w w w.j a va 2 s. c om*/ public boolean accept(File dir, String name) { return name.toUpperCase().endsWith(".XML"); } }); for (File file : files) { uploadFile(file, cmdline, modelPort); } }
From source file:com.coinblesk.client.backup.BackupRestoreDialogFragment.java
private void cleanupBeforeRestore() { stopWalletService();/*from ww w .ja v a 2s. c o m*/ // clear files directory (by moving everything to an archive folder) File filesDir = getActivity().getFilesDir(); File archiveDir = new File(filesDir, "archive_" + System.currentTimeMillis()); File[] filesInFilesDir = filesDir.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String filename) { // exclude archive dirs return !filename.startsWith("archive_"); } }); for (File file : filesInFilesDir) { try { FileUtils.moveToDirectory(file, archiveDir, true); Log.d(TAG, "Moved file '" + file + "' to '" + archiveDir + "'"); } catch (IOException e) { Log.w(TAG, "Could not move file: " + file.toString()); } } }
From source file:com.qmetry.qaf.automation.util.FileUtil.java
/** * @param fname//from w w w. ja va2s . c o m * : file name or part of file name to search * @param comparator * : comparator to use while filtering file. * @return: FilenameFilter Example: * <ol> * <li>getFileFilterFor(".properties", StringComparator.Suffix) * <li>getFileFilterFor("TC123", StringComparator.Prefix) * <li>getFileFilterFor("TC123.*.png", StringComparator.RegExp) * </ol> */ public static FilenameFilter getFileFilterFor(final String fname, StringComparator comparator) { final StringComparator fnamecomparator = null != comparator ? comparator : StringComparator.In; FilenameFilter filter = new FilenameFilter() { public boolean accept(File dir, String name) { return fnamecomparator.compareIgnoreCase(name, fname); } }; return filter; }
From source file:com.rapid.core.Pages.java
public Pages(Application application) throws RapidLoadingException, ParserConfigurationException, XPathExpressionException, SAXException, IOException { // get a logger _logger = Logger.getLogger(Pages.class); // store the application _application = application;//from www . jav a 2 s .co m // initialise the page headers collection _pageHeaders = new HashMap<String, PageHeader>(); // initialise the pages collection _pages = new HashMap<String, Page>(); // create a filter for finding .page.xml files _filenameFilter = new FilenameFilter() { public boolean accept(File dir, String name) { return name.toLowerCase().endsWith(".page.xml"); } }; // make a page sorter _pageSorter = new PageSorter(application); }
From source file:br.upe.ecomp.dosa.view.mainwindow.MainWindowActions.java
private void openTestScenario() { FileDialog fileopen = new FileDialog(this, "Open Test Scenario", FileDialog.LOAD); fileopen.setFilenameFilter(new FilenameFilter() { @Override//from ww w .j a v a2 s . co m public boolean accept(File dir, String name) { return name.toLowerCase().endsWith("xml"); } }); fileopen.setVisible(true); if (fileopen.getFile() != null) { filePath = fileopen.getDirectory(); fileName = fileopen.getFile(); algorithm = AlgorithmXMLParser.read(filePath, fileName); configureTree(); updateToolBarButtonsState(); ((CardLayout) panelTestScenario.getLayout()).last(panelTestScenario); } }
From source file:kr.ac.kaist.wala.hybridroid.shell.Shell.java
/** * For multiple file analysis. Not support now. * /*from w ww . ja va 2s.co m*/ * @param target * the directory path that includes the target files. * @return list of target files. */ private static List<File> getTargetFiles(String target) { File targetFile = new File(target); List<File> fileList = new ArrayList<File>(); if (targetFile.isDirectory()) { File[] tmpList = targetFile.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { // TODO Auto-generated method stub if (name.endsWith(".apk")) return true; else return false; } }); for (File f : tmpList) fileList.add(f); } else { fileList.add(targetFile); } return fileList; }
From source file:fr.inria.eventcloud.deployment.cli.launchers.EventCloudsManagementServiceDeployer.java
private static String addClassPath(String libsUrl) throws IOException { downloadLibs(libsUrl);/*from w w w . j a va2s .c om*/ File libDir = new File(libDirPath); String[] libNames = libDir.list(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.endsWith(".jar"); } }); StringBuilder classPath = new StringBuilder(); for (String libName : libNames) { classPath.append(libDirPath).append(File.separator).append(libName).append(File.pathSeparator); } classPath.delete(classPath.length() - 2, classPath.length() - 1); return classPath.toString(); }
From source file:org.geoserver.web.admin.GlobalSettingsPage.java
private void logLevelsAppend(Form form, IModel loggingInfoModel) { // search for *LOGGING.properties files in the data directory GeoServerResourceLoader loader = GeoServerApplication.get().getBeanOfType(GeoServerResourceLoader.class); List<String> logProfiles = null; try {/*from w w w . j a va 2 s . c o m*/ File logsDirectory = loader.find("logs"); if (logsDirectory.exists() && logsDirectory.isDirectory()) { String[] propFiles = logsDirectory.list(new FilenameFilter() { public boolean accept(File dir, String name) { return name.toLowerCase().endsWith("logging.properties"); } }); logProfiles = Arrays.asList(propFiles); Collections.sort(logProfiles, String.CASE_INSENSITIVE_ORDER); } } catch (Exception e) { LOGGER.log(Level.WARNING, "Could not load the list of log configurations from the data directory", e); } // if none is found use the default set if (logProfiles == null || logProfiles.size() == 0) logProfiles = DEFAULT_LOG_PROFILES; form.add(new ListChoice("log4jConfigFile", new PropertyModel(loggingInfoModel, "level"), logProfiles)); }