List of usage examples for java.io FilenameFilter FilenameFilter
FilenameFilter
From source file:com.sonar.it.java.suite.TestUtils.java
public static File pluginJar(String artifactId) { return Iterables.getOnlyElement(Arrays .asList(new File(homeDir(), "plugins/" + artifactId + "/target/").listFiles(new FilenameFilter() { @Override/*w ww . j av a 2s . c o m*/ public boolean accept(File dir, String name) { return name.endsWith(".jar") && !name.endsWith("-sources.jar"); } }))); }
From source file:File.TXT.ReadFile.java
public ArrayList read_all_files(String path) { FilenameFilter filter = new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith(".txt"); }//from www . j av a 2s .c om }; ArrayList hasil = new ArrayList(); File folder = new File(path); File[] listOfFiles = folder.listFiles(filter); for (int i = 0; i < listOfFiles.length; i++) { File file = listOfFiles[i]; try { if (file.canRead()) { String content = FileUtils.readFileToString(file); hasil.add(content); } else { hasil.add("kosong"); } } catch (IOException ex) { Logger.getLogger(ReadFile.class.getName()).log(Level.SEVERE, null, ex); } } return hasil; }
From source file:gov.nih.nci.ncicb.tcga.dcc.qclive.common.util.DirectoryListerImpl.java
/** * Convenience method to statically get list of files in dir by extension. * @param dirName the directory in which to look * @param extension the extension the files must have * @return array of File objects//from w w w .ja v a 2 s . c o m */ public static File[] getFilesByExtension(final String dirName, final String extension) { final File dir = new File(dirName); // It is also possible to filter the list of returned files. // This does not return any files that start with `.'. final FilenameFilter filter = new FilenameFilter() { public boolean accept(final File dir, final String name) { return name.toLowerCase().endsWith(extension.toLowerCase()) && !name.startsWith("."); } }; return dir.listFiles(filter) != null ? dir.listFiles(filter) : null; }
From source file:edu.uci.ics.asterix.installer.transaction.RecoveryIT.java
@BeforeClass public static void setUp() throws Exception { File outdir = new File(PATH_ACTUAL); outdir.mkdirs();//w ww .j a v a 2 s . c o m asterixInstallerPath = new File(System.getProperty("user.dir")); installerTargetPath = new File(asterixInstallerPath, "target"); managixHomeDirName = installerTargetPath.list(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return new File(dir, name).isDirectory() && name.startsWith("asterix-installer") && name.endsWith("binary-assembly"); } })[0]; managixHomePath = new File(installerTargetPath, managixHomeDirName).getAbsolutePath(); LOGGER.info("MANAGIX_HOME=" + managixHomePath); pb = new ProcessBuilder(); env = pb.environment(); env.put("MANAGIX_HOME", managixHomePath); scriptHomePath = asterixInstallerPath + File.separator + "src" + File.separator + "test" + File.separator + "resources" + File.separator + "transactionts" + File.separator + "scripts"; env.put("SCRIPT_HOME", scriptHomePath); TestsUtils.executeScript(pb, scriptHomePath + File.separator + "setup_teardown" + File.separator + "configure_and_validate.sh"); TestsUtils.executeScript(pb, scriptHomePath + File.separator + "setup_teardown" + File.separator + "stop_and_delete.sh"); }
From source file:br.edimarmanica.trinity.intrasitemapping.manual.AllMappings.java
public void execute() { File dir = new File(Paths.PATH_TRINITY + site.getPath() + "/offset"); for (File offset : dir.listFiles(new FilenameFilter() { @Override//w w w. j a va 2 s . co m public boolean accept(File dir, String name) { return name.endsWith(".csv"); } })) { Mapping map = new Mapping(site, offset); Map<Attribute, Integer> maps = map.getBestGroups(); for (Attribute attr : maps.keySet()) { List<String> dataRecord = new ArrayList<>(); dataRecord.add(attr.getAttributeID()); dataRecord.add(offset.getName()); dataRecord.add(maps.get(attr).toString()); print(dataRecord); } } }
From source file:ImageSorter.java
/** * @param in//from w ww .j av a2 s.c o m * @param leftOut * @param rightOut */ public ImageSorter(String in, String leftOut, String rightOut) { super("ImageSorter"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); inputs = new File(in).listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { String s = name.toLowerCase(); return s.endsWith("jpg"); } }); leftOutput = new File(in, leftOut); rightOutput = new File(in, rightOut); leftOutput.mkdirs(); rightOutput.mkdirs(); assert leftOutput.canWrite(); assert rightOutput.canWrite(); panel.setPreferredSize(new Dimension(640, 480)); getContentPane().setLayout(new BorderLayout()); getContentPane().add(panel, BorderLayout.CENTER); panel.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_RIGHT) { inputs[index].renameTo(new File(rightOutput, inputs[index].getName())); } else if (e.getKeyCode() == KeyEvent.VK_LEFT) { inputs[index].renameTo(new File(leftOutput, inputs[index].getName())); } nextImage(); } }); panel.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { panel.requestFocusInWindow(); } @Override public void mousePressed(MouseEvent e) { panel.requestFocusInWindow(); } @Override public void mouseEntered(MouseEvent e) { panel.requestFocusInWindow(); } @Override public void mouseClicked(MouseEvent e) { panel.requestFocusInWindow(); } }); panel.requestFocusInWindow(); nextImage(); pack(); setVisible(true); }
From source file:com.krzysztofzabinski.publication1.Remover.java
public static void readRules() { File inputDirectory = new File("rules/."); inputFilesRules = inputDirectory.listFiles(new FilenameFilter() { @Override//w w w . j a va 2 s. c o m public boolean accept(File dir, String name) { return name.toLowerCase().endsWith(".csv"); } }); for (File file : inputFilesRules) { List<String> tmpList = new ArrayList<>(); BufferedReader reader = null; String line; try { reader = new BufferedReader(new FileReader(file.getAbsolutePath())); while ((line = reader.readLine()) != null) { tmpList.add(line); } } catch (FileNotFoundException e) { } catch (IOException e) { } finally { if (reader != null) { try { reader.close(); } catch (IOException e) { } } } inputRules.add(tmpList); } }
From source file:com.consol.citrus.admin.util.FileHelperImpl.java
/** * {@inheritDoc}//from w w w . ja v a 2 s . com */ public String[] getFolders(File directory) { if (directory.exists()) { String[] files = directory.list(new FilenameFilter() { public boolean accept(File dir, String name) { return name.charAt(0) != '.' && new File(dir, name).isDirectory(); } }); if (files != null) { Arrays.sort(files, String.CASE_INSENSITIVE_ORDER); return files; } else { return new String[] {}; } } else { throw new CitrusAdminRuntimeException( "Could not open directory because it does not exist: " + directory); } }
From source file:de.zib.gndms.infra.system.PluginLoader.java
public URLClassLoader loadPlugins() throws IOException { final ArrayList<URL> jars; final File pluginDir = new File(pluginPath); final String[] list = pluginDir.list(new FilenameFilter() { @Override/*from w w w .j a v a 2 s .c o m*/ public boolean accept(final File dir, final String name) { return name.matches(".*\\.jar"); } }); if (list != null) { jars = new ArrayList<URL>(list.length); for (int i = 0; i < list.length; ++i) jars.add(new URL("file://" + pluginPath + File.separator + list[i])); return new URLClassLoader(jars.toArray(new URL[jars.size()]), this.getClass().getClassLoader()); } return new URLClassLoader(new URL[] {}, this.getClass().getClassLoader()); }
From source file:br.edimarmanica.trinity.intrasitemapping.auto.MergeOffsets.java
public void execute() { mc = new MappingController(site); mc.execute();/*from ww w. j a v a2s . c om*/ File dir = new File(Paths.PATH_TRINITY + site.getPath() + "/offset"); for (int indexOffset = 0; indexOffset < dir.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.endsWith(".csv"); } }).length; indexOffset++) { executeOffset(indexOffset); } }