Example usage for java.io FilenameFilter FilenameFilter

List of usage examples for java.io FilenameFilter FilenameFilter

Introduction

In this page you can find the example usage for java.io FilenameFilter FilenameFilter.

Prototype

FilenameFilter

Source Link

Usage

From source file:eu.udig.omsbox.OmsBoxPlugin.java

/**
 * Adds custom libs from the plugins./*  w w  w.j av  a  2 s  .  c om*/
 * 
 * FIXME this should hopefully get better at some point. 
 * 
 * @throws IOException 
 */
private void addCustomLibs(StringBuilder sb) throws IOException {
    // add some extra jars that are locked inside some eclipse plugins
    Bundle log4jBundle = Platform.getBundle("org.apache.log4j");
    String log4jFolderPath = getPath(log4jBundle, "/");
    if (log4jFolderPath != null) {
        sb.append(File.pathSeparator);
        addPath(log4jFolderPath + File.separator + "*", sb);
    }
    Bundle itextBundle = Platform.getBundle("com.lowagie.text");

    String itextPath = getPath(itextBundle, "/");
    if (itextPath != null) {
        itextPath = itextPath.replaceAll("!", "");
        sb.append(File.pathSeparator);
        addPath(itextPath, sb);
    }

    Location installLocation = Platform.getInstallLocation();
    File installFolder = DataUtilities.urlToFile(installLocation.getURL());
    if (installFolder != null && installFolder.exists()) {
        File pluginsFolder = new File(installFolder, "plugins");
        if (pluginsFolder.exists()) {

            File[] files = pluginsFolder.listFiles(new FilenameFilter() {
                public boolean accept(File dir, String name) {
                    boolean isCommonsLog = name.startsWith("org.apache.commons.logging_")
                            && name.endsWith(".jar");
                    return isCommonsLog;
                }
            });
            if (files.length > 1) {
                sb.append(File.pathSeparator);
                addPath(files[0].getAbsolutePath(), sb);
            }
            files = pluginsFolder.listFiles(new FilenameFilter() {
                public boolean accept(File dir, String name) {
                    boolean isJunit = name.startsWith("junit") && name.endsWith(".jar");
                    return isJunit;
                }
            });
            if (files.length > 1) {
                sb.append(File.pathSeparator);
                addPath(files[0].getAbsolutePath(), sb);
            }
        }
    }
}

From source file:eu.asterics.mw.services.TestResourceRegistry.java

@Test
public void testGetLicensesListForRemoteWindow() {
    ResourceRegistry.getInstance().setAREBaseURI(new File("../bin/ARE").toURI().normalize());
    final String compType = "actuator.RemoteWindow";
    System.out.println("Licenses of compType: " + compType);
    for (URI componentJarURI : ResourceRegistry.getInstance().getLicensesList(new FilenameFilter() {

        @Override/*from w  w  w.ja v  a  2  s  .  c o m*/
        public boolean accept(File dir, String name) {
            String[] compTypePrefix = name.split("-");
            return compTypePrefix[0].equalsIgnoreCase(compType) && name.endsWith(".txt");
        }

    }, false)) {
        System.out.println(componentJarURI);
    }
}

From source file:com.isencia.passerelle.runtime.repos.impl.filesystem.FlowRepositoryServiceImpl.java

private FlowHandle readAndBuildFlowHandle(String code, File versionFolder) {
    if (!versionFolder.isDirectory()) {
        return null;
    } else {// ww w  .  jav  a  2  s.c  o  m
        try {
            VersionSpecification vSpec = VersionSpecification.parse(versionFolder.getName());
            File[] modelFiles = versionFolder.listFiles(new FilenameFilter() {
                @Override
                public boolean accept(File dir, String name) {
                    return name.endsWith("moml") || name.endsWith("xml");
                }
            });
            File modelFile = modelFiles[0];
            return new FlowHandleImpl(code, modelFile, vSpec);
        } catch (Exception e) {
            return null;
        }
    }
}

From source file:net.grinder.engine.agent.PropertyBuilder.java

/**
 * Build custom class path based on the jar files on given base path.
 *
 * @param useAbsolutePath true if the class path entries should be represented as
 *                        absolute path//  w w  w .j  a v  a  2s  .c  om
 * @return classpath string
 */
@SuppressWarnings("ResultOfMethodCallIgnored")
public String buildCustomClassPath(final boolean useAbsolutePath) {
    File baseFile = baseDirectory.getFile();
    File libFolder = new File(baseFile, "lib");
    final StringBuffer customClassPath = new StringBuffer();
    customClassPath.append(getPath(baseFile, useAbsolutePath));
    if (libFolder.exists()) {
        customClassPath.append(File.pathSeparator).append(getPath(new File(baseFile, "lib"), useAbsolutePath));
        libFolder.list(new FilenameFilter() {
            @Override
            public boolean accept(File dir, String name) {
                if (name.endsWith(".jar")) {
                    customClassPath.append(File.pathSeparator)
                            .append(getPath(new File(dir, name), useAbsolutePath));
                }
                return true;
            }
        });
    }
    return customClassPath.toString();
}

From source file:de.mprengemann.intellij.plugin.androidicons.forms.MaterialIconsImporter.java

private void fillColors() {
    final String lastSelectedColor = this.lastSelectedColor;
    colorSpinner.removeAllItems();/* w ww. j  a v  a  2s . co m*/
    if (this.assetRoot.getCanonicalPath() == null) {
        return;
    }
    File assetRoot = new File(this.assetRoot.getCanonicalPath());
    assetRoot = new File(assetRoot, (String) categorySpinner.getSelectedItem());
    assetRoot = new File(assetRoot, DEFAULT_RESOLUTION);
    final String assetName = (String) assetSpinner.getSelectedItem();
    final String assetSize = (String) sizeSpinner.getSelectedItem();
    final FilenameFilter drawableFileNameFiler = new FilenameFilter() {
        @Override
        public boolean accept(File file, String s) {
            if (!FilenameUtils.isExtension(s, "png")) {
                return false;
            }
            String filename = FilenameUtils.removeExtension(s);
            return filename.startsWith("ic_" + assetName + "_") && filename.endsWith("_" + assetSize);
        }
    };
    File[] assets = assetRoot.listFiles(drawableFileNameFiler);
    Set<String> colors = new HashSet<String>();
    for (File asset : assets) {
        String drawableName = FilenameUtils.removeExtension(asset.getName());
        String[] color = drawableName.split("_");
        drawableName = color[color.length - 2].trim();
        colors.add(drawableName);
    }
    List<String> list = new ArrayList<String>();
    list.addAll(colors);
    Collections.sort(list);
    for (String size : list) {
        colorSpinner.addItem(size);
    }
    if (list.contains(lastSelectedColor)) {
        colorSpinner.setSelectedIndex(list.indexOf(lastSelectedColor));
    }
}

From source file:interactivespaces.workbench.tasks.WorkbenchTaskContext.java

/**
 * Add all extension classpath entries that the controller specifies.
 *
 * @param files/*from   w  w w. jav  a2 s . com*/
 *          the list of files to add to.
 */
private void addControllerExtensionsClasspath(List<File> files) {
    File[] extensionFiles = fileSupport.newFile(
            fileSupport.newFile(getControllerDirectory(), ContainerFilesystemLayout.FOLDER_DEFAULT_CONFIG),
            ContainerFilesystemLayout.FOLDER_CONFIG_ENVIRONMENT).listFiles(new FilenameFilter() {
                @Override
                public boolean accept(File dir, String name) {
                    return name.endsWith(EXTENSION_FILE_EXTENSION);
                }
            });

    if (extensionFiles != null) {
        for (File extensionFile : extensionFiles) {
            processExtensionFile(files, extensionFile, getControllerDirectory());
        }
    }
}

From source file:com.hurence.logisland.documentation.DocGenerator.java

/**
 * Checks to see if a directory to write to has an additionalDetails.html in
 * it already.//from w  w  w. j a v  a 2 s . com
 *
 * @param directory to check
 * @return true if additionalDetails.html exists, false otherwise.
 */
private static boolean hasAdditionalInfo(File directory) {
    return directory.list(new FilenameFilter() {

        @Override
        public boolean accept(File dir, String name) {
            return name.equalsIgnoreCase(HtmlDocumentationWriter.ADDITIONAL_DETAILS_HTML);
        }

    }).length > 0;
}

From source file:de.xirp.ate.ATEManager.java

/**
 * Starts the {@link de.xirp.ate.ATEManager}. The
 * existing class files are read and added to the set of class
 * names. Finally the nessessary listerns are registered. <br>
 * <br>/*from   w w  w  .  j  ava 2  s. c o m*/
 * This method is called from the
 * {@link de.xirp.managers.ManagerFactory} on
 * startup. Do not call it on your own.
 * 
 * @see de.xirp.managers.AbstractManager#start()
 */
@Override
protected void start() throws ManagerException {
    super.start();
    File dir = new File(Constants.MAZE_CODE_DIR);
    FilenameFilter filter = new FilenameFilter() {

        public boolean accept(File dir, String name) {
            return name.endsWith(".class"); //$NON-NLS-1$
        }

    };
    for (File file : dir.listFiles(filter)) {
        mazeJavaClasses.add(extractClassName(file.getName()));
    }

    currentMaze.addMazeListener(new MazeListener() {

        public void mazeModified(Maze maze) {

        }

    });
}

From source file:com.jayway.maven.plugins.android.phase09package.ApklibMojo.java

/**
 * Adds all shared libraries (.so) to a {@link JarArchiver} under 'libs'.
 * //from  w w  w  .  j av a2s.  com
 * @param jarArchiver The jarArchiver to add files to
 * @param directory   The directory to scan for .so files
 * @param architecture      The prefix for where in the jar the .so files will go.
 */
protected void addSharedLibraries(JarArchiver jarArchiver, File directory, String architecture) {
    getLog().debug("Searching for shared libraries in " + directory);
    File[] libFiles = directory.listFiles(new FilenameFilter() {
        public boolean accept(final File dir, final String name) {
            return name.startsWith("lib") && name.endsWith(".so");
        }
    });

    if (libFiles != null) {
        for (File libFile : libFiles) {
            String dest = NATIVE_LIBRARIES_FOLDER + "/" + architecture + "/" + libFile.getName();
            getLog().debug("Adding " + libFile + " as " + dest);
            jarArchiver.addFile(libFile, dest);
        }
    }
}