List of usage examples for java.io FilenameFilter FilenameFilter
FilenameFilter
From source file:de.unisb.cs.st.javalanche.rhino.RhinoTestDriver.java
private static File[] getTestFilesForDir(File dir) { List<File> filesList = new ArrayList<File>(); File[] files = dir.listFiles(); for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { File[] dirs = files[i].listFiles(); for (int j = 0; j < dirs.length; j++) { if (dirs[j].isDirectory()) { File[] subFiles = dirs[j].listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith(".js"); }//from ww w .ja v a 2 s . c o m }); filesList.addAll(Arrays.asList(subFiles)); } } } } return filesList.toArray(new File[0]); }
From source file:hmp.HMPClassiferSummary.java
private File[] getFiles(File directory) { return directory.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { if (name.endsWith(fileSuffix)) { return true; }//from ww w . ja v a2 s .c om return false; } }); }
From source file:edu.ku.brc.specify.config.init.TaxonLoadSetupPanel.java
/** * Creates a dialog for entering database name and selecting the appropriate driver. *//*from w w w . j a v a 2 s .c om*/ public TaxonLoadSetupPanel(final String helpContext, final JButton nextBtn, final JButton prevBtn) { super("PRELOADTXN", helpContext, nextBtn, prevBtn); String header = getResourceString("PRELOADTXN_INFO"); CellConstraints cc = new CellConstraints(); String rowDef = "p,10px," + createDuplicateJGoodiesDef("p", "2px", 8) + ",p:g"; PanelBuilder builder = new PanelBuilder(new FormLayout("p,2px,p:g", rowDef), this); int row = 1; stdSep = builder.add(createLabel(header, SwingConstants.CENTER), cc.xywh(1, row, 3, 1)); row += 2; fileCBX = createComboBox(); srcTF = createTextField(""); coverageTF = createTextField(""); descTA = createTextArea(); otherBrw = new ValBrowseBtnPanel(otherTF = new ValTextField(), false, true); otherBrw.setUseNativeFileDlg(true); descTA.setEditable(false); descTA.setColumns(30); descTA.setRows(5); descTA.setWrapStyleWord(true); descTA.setLineWrap(true); ViewFactory.changeTextFieldUIForDisplay(srcTF, false); ViewFactory.changeTextFieldUIForDisplay(coverageTF, false); builder.add(preloadChk = createI18NCheckBox("TFD_LOAD_TAXON"), cc.xy(1, row)); row += 2; builder.addSeparator(UIRegistry.getResourceString("TFD_SEP_STD"), cc.xyw(1, row, 3)); row += 2; builder.add(fileLbl = createI18NFormLabel("TFD_FILE_LBL"), cc.xy(1, row)); builder.add(fileCBX, cc.xy(3, row)); row += 2; builder.add(srcLbl = createI18NFormLabel("TFD_SRC_LBL"), cc.xy(1, row)); builder.add(srcTF, cc.xy(3, row)); row += 2; builder.add(coverageLbl = createI18NFormLabel("TFD_CVRG_LBL"), cc.xy(1, row)); builder.add(coverageTF, cc.xy(3, row)); row += 2; builder.add(descLbl = createI18NFormLabel("TFD_DESC_LBL"), cc.xy(1, row)); builder.add(createScrollPane(descTA), cc.xy(3, row)); row += 2; //othSep = builder.addSeparator(UIRegistry.getResourceString("TFD_SEP_OTH"), cc.xyw(1, row, 3)); row += 2; //builder.add(otherLbl = createI18NFormLabel("TFD_OTHER_LBL"), cc.xy(1, row)); //builder.add(otherBrw, cc.xy(3, row)); row += 2; updateBtnUI(); otherTF.getDocument().addDocumentListener(new DocumentAdaptor() { @Override protected void changed(DocumentEvent e) { updateBtnUI(); } }); preloadChk.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean checked = preloadChk.isSelected(); if (checked) { if (fileCBX.getModel().getSize() > 0 && fileCBX.getSelectedIndex() == -1) { fileCBX.setSelectedIndex(0); } enableUI(otherTF.getText().isEmpty(), true, true); } else { enableUI(false, true, false); } } }); otherTF.addFocusListener(new FocusAdapter() { /* (non-Javadoc) * @see java.awt.event.FocusAdapter#focusLost(java.awt.event.FocusEvent) */ @Override public void focusLost(FocusEvent e) { updateBtnUI(); } }); otherBrw.setNativeDlgFilter(new FilenameFilter() { /* (non-Javadoc) * @see java.io.FilenameFilter#accept(java.io.File, java.lang.String) */ @Override public boolean accept(File dir, String name) { return name.toLowerCase().endsWith(XLS); } }); }
From source file:de.mprengemann.intellij.plugin.androidicons.forms.MaterialIconsImporter.java
private void fillCategories() { categorySpinner.removeAllItems();//from w w w . jav a2s. c o m if (this.assetRoot.getCanonicalPath() == null) { return; } File assetRoot = new File(this.assetRoot.getCanonicalPath()); final FilenameFilter folderFileNameFiler = new FilenameFilter() { @Override public boolean accept(File file, String s) { return !s.startsWith(".") && new File(file, s).isDirectory() && !PluginSettings.BLACKLISTED_MATERIAL_ICONS_FOLDER .contains(FilenameUtils.removeExtension(s)); } }; File[] categories = assetRoot.listFiles(folderFileNameFiler); Arrays.sort(categories, alphabeticalComparator); for (File file : categories) { categorySpinner.addItem(file.getName()); } }
From source file:gdsc.smlm.ij.plugins.pcpalm.PCPALMAnalysis.java
/** * Load all the results from a directory. File must have the XML suffix * /*from w ww . j a v a 2 s . c o m*/ * @return DONE */ private int loadResults() { if (getDirectory()) { File[] fileList = (new File(resultsDirectory)).listFiles(new FilenameFilter() { public boolean accept(File arg0, String arg1) { return arg1.endsWith("xml"); } }); if (fileList == null) return DONE; int count = 0; for (int i = 0; i < fileList.length; i++) { XStream xs = new XStream(new DomDriver()); if (fileList[i].isFile()) if (loadResult(xs, fileList[i].getPath())) count++; } if (count > 0) Collections.sort(results); log("Loaded %d results", count); } return DONE; }
From source file:hudson.maven.RedeployPublisherTest.java
@Test public void testTarGzMaven3() throws Exception { MavenModuleSet m3 = j.createMavenProject(); MavenInstallation mvn = j.configureMaven3(); m3.setMaven(mvn.getName());/*from w w w .j a v a 2s .c o m*/ File repo = tmp.getRoot(); // a fake build m3.setScm(new SingleFileSCM("pom.xml", getClass().getResource("targz-artifact.pom"))); m3.getPublishersList().add(new RedeployPublisher("", repo.toURI().toString(), false, false)); MavenModuleSetBuild b = m3.scheduleBuild2(0).get(); j.assertBuildStatus(Result.SUCCESS, b); assertTrue(MavenUtil.maven3orLater(b.getMavenVersionUsed())); File artifactDir = new File(repo, "test/test/0.1-SNAPSHOT/"); String[] files = artifactDir.list(new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith("tar.gz"); } }); assertFalse("tar.gz doesn't exist", new File(repo, "test/test/0.1-SNAPSHOT/test-0.1-SNAPSHOT-bin.tar.gz").exists()); assertTrue("tar.gz doesn't exist", !files[0].contains("SNAPSHOT")); }
From source file:de.unisb.cs.st.javalanche.rhino.coverage.CoberturaParser.java
private static File[] getXmlFiles() { String dirName = "/scratch/schuler/subjects/ibugs_rhino-0.1/coverage-report/"; File dir = new File(dirName); File[] files = dir.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { if (name.endsWith("xml")) { return true; }//from www .j a v a 2 s . co m return false; } }); return files; }
From source file:gov.nasa.ensemble.common.io.FileUtilities.java
/** * /*from www . j a va 2s .c o m*/ * @param directory * @param extension * @return A list of fileNames in the directory with the specified extension. */ public static String[] getAllFileNamesWithExtension(File directory, final String extension) { String[] ret = directory.list(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.endsWith(extension); } }); return ret == null ? new String[0] : ret; }
From source file:com.googlecode.flyway.commandline.Main.java
/** * Loads all the jars contained in the jars folder. (For Jdbc drivers and Java Migrations) * * @throws IOException When the jars could not be loaded. *//* w w w . j a v a 2 s.com*/ private static void loadJdbcDriversAndJavaMigrations() throws Exception { final String directoryForJdbcDriversAndJavaMigrations = getInstallationDir() + "/jars"; File dir = new File(directoryForJdbcDriversAndJavaMigrations); File[] files = dir.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith(".jar"); } }); // see javadoc of listFiles(): null if given path is not a real directory if (files == null) { LOG.warn("Directory for JDBC drivers and JavaMigrations not found: " + directoryForJdbcDriversAndJavaMigrations); return; } for (File file : files) { addJarOrDirectoryToClasspath(file.getPath()); } }
From source file:backtype.storm.localizer.Localizer.java
protected File[] readCurrentBlobs(String location) { File dir = new File(location); File[] files = null;/*w ww . j a va 2 s . c om*/ if (dir.exists()) { files = dir.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.toLowerCase().endsWith(Utils.DEFAULT_CURRENT_BLOB_SUFFIX); } }); } return files; }