Example usage for org.apache.commons.io FilenameUtils isExtension

List of usage examples for org.apache.commons.io FilenameUtils isExtension

Introduction

In this page you can find the example usage for org.apache.commons.io FilenameUtils isExtension.

Prototype

public static boolean isExtension(String filename, Collection<String> extensions) 

Source Link

Document

Checks whether the extension of the filename is one of those specified.

Usage

From source file:edu.cornell.med.icb.goby.modes.LastToCompactMode.java

@Override
protected int scan(final ReadSet readIndexFilter, final IndexedIdentifier targetIds,
        final AlignmentWriter writer, final AlignmentTooManyHitsWriter tmhWriter) throws IOException {

    int currentQueryIndex = -1;
    final List<Alignments.AlignmentEntry.Builder> sameQueryIndexAlignmentEntries = new ArrayList<Alignments.AlignmentEntry.Builder>();

    int numAligns = 0;

    // remove extension from inputFile
    if (FilenameUtils.isExtension(inputFile, new String[] { "maf", "counts" })) {
        inputFile = FilenameUtils.removeExtension(inputFile);
    }//from w w  w .  j ava 2  s . c  o m
    final String mafInputFile = inputFile + ".maf";
    final String countsInputFile = inputFile + ".counts";

    // convert MAF to compact alignment
    if (!onlyCountsFile) {

        // initialize minimum score & num hits maps
        final Int2FloatOpenHashMap queryIndexToMaxAlignmentScore = new Int2FloatOpenHashMap();
        final Int2IntOpenHashMap queryIndexToNumHitsAtMaxScore = new Int2IntOpenHashMap();

        final AlignmentStats stats = new AlignmentStats();
        //      final int[] readLengths = createReadLengthArray();
        IntArrayList targetLengths = new IntArrayList();
        // first pass: collect minimum score to keep each queryEntry
        // second pass: write to compact alignment file for those entries with score above threshold
        for (final boolean writeAlignment : new boolean[] { false, true }) {
            assert new File(mafInputFile).exists() : "Missing MAF file: " + mafInputFile;
            final LastParser parser = new LastParser(new FileReader(mafInputFile));

            //
            final ProgressLogger progress = new ProgressLogger(LOG);
            progress.start();
            numAligns = 0;
            int removedByQualityFilter = 0;
            int notBestScore = 0;
            while (parser.hasNext()) {
                // parse maf alignment entry
                parser.next();
                final float score = parser.getScore();
                final ObjectArrayList<AlignedSequence> alignedSequences = parser.getAlignedSequences();

                // retrieve alignment properties
                final AlignedSequence reference = alignedSequences.get(0);
                final AlignedSequence query = alignedSequences.get(1);
                if (flipStrand) {
                    // override the query strand with forceStrand if requested on the command line.
                    query.strand = query.strand == '+' ? '-' : query.strand == '-' ? '+' : '?';
                    flip(reference.alignment);
                    flip(query.alignment);
                }
                if (substituteCharacter) {
                    for (final Substitution sub : substitutions) {
                        query.alignment.replace(sub.from, sub.to);
                    }
                }
                final int queryIndex = Integer.parseInt(query.sequenceIdentifier.toString());
                if (currentQueryIndex == -1) {
                    currentQueryIndex = queryIndex;
                }
                largestQueryIndex = Math.max(queryIndex, largestQueryIndex);
                int targetIndex = -1;
                targetIndex = getTargetIndex(targetIds, reference.sequenceIdentifier, thirdPartyInput);
                final boolean reverseStrand = !(query.strand == reference.strand);
                final int depth = query.sequenceLength;
                final int targetPosition = reference.alignedStart;

                // we have a multiplicity filter. Use it to determine multiplicity.
                int multiplicity = 1;
                if (readIndexFilter != null) {
                    /* Multiplicity of a read is the number of times the (exact) sequence
                     * of the read is identically repeated across a sample file.  The filter
                     * removes duplicates to avoid repeating the same alignments.  Once
                     * aligned, these are recorded multiplicity times.
                     */
                    multiplicity = readIndexFilter.getMultiplicity(queryIndex);
                }

                evaluateStatistics(reference, query, stats);

                final Alignments.AlignmentEntry.Builder currentEntry = Alignments.AlignmentEntry.newBuilder();
                currentEntry.setNumberOfIndels(stats.numberOfIndels);
                currentEntry.setNumberOfMismatches(stats.numberOfMismatches);
                currentEntry.setMatchingReverseStrand(reverseStrand);
                currentEntry.setMultiplicity(multiplicity);
                currentEntry.setPosition(targetPosition);
                currentEntry.setQueryAlignedLength(query.alignedLength);
                currentEntry.setQueryIndex(queryIndex);
                currentEntry.setScore(score);
                currentEntry.setTargetAlignedLength(reference.alignedLength);
                if (targetLengths.size() <= targetIndex) {
                    targetLengths.size(targetIndex + 1);
                }
                targetLengths.set(targetIndex, reference.sequenceLength);
                currentEntry.setTargetIndex(targetIndex);
                final int queryLength = query.sequenceLength;
                currentEntry.setQueryLength(queryLength);
                final int readStartPosition = query.alignedStart;

                parseSequenceVariations(currentEntry, reference, query, readStartPosition, queryLength,
                        reverseStrand);

                if (qualityFilter.keepEntry(depth, currentEntry)) {
                    final float currentMax = queryIndexToMaxAlignmentScore.get(queryIndex);
                    final int currentNumHits = queryIndexToNumHitsAtMaxScore.get(queryIndex);
                    // on the first pass, writeAlignment=false
                    if (!writeAlignment) {
                        // save the maximum score per read
                        //   and reset the counter to reflect numHits at this new value
                        if (score > currentMax) {
                            queryIndexToMaxAlignmentScore.put(queryIndex, score);
                            queryIndexToNumHitsAtMaxScore.put(queryIndex, 1);
                        }
                        // if query score equals the current max, add 1 to the counter
                        if (score == currentMax) {
                            queryIndexToNumHitsAtMaxScore.put(queryIndex, currentNumHits + 1);
                        }
                    } else {
                        // on the second pass, writeAlignment=true
                        // write the maximum scoring entry (or entries) per read
                        if (score == currentMax) {
                            // only write non-ambiguous entries i.e. currentNumHits <= mParameter
                            if (currentNumHits <= mParameter) {

                                if (currentEntry.getQueryIndex() == currentQueryIndex) {
                                    sameQueryIndexAlignmentEntries.add(currentEntry);
                                } else {
                                    writeEntries(writer, sameQueryIndexAlignmentEntries);
                                    sameQueryIndexAlignmentEntries.add(currentEntry);
                                    currentQueryIndex = currentEntry.getQueryIndex();
                                    numAligns += multiplicity;
                                }
                            }
                            // TMH writer adds the alignment entry only if hits > thresh
                        } else {
                            notBestScore++;
                            //        System.out.println("Excluding entry "+alignmentEntry);
                        }
                    }
                } else {
                    removedByQualityFilter++;
                }

                progress.lightUpdate();
            }
            parser.close();
            if (writeAlignment) {
                // Write the remaining entries (last query index);
                writeEntries(writer, sameQueryIndexAlignmentEntries);
                /*System.out.println("============== LastToCompact dumping targetLengths..");
                final DoubleIndexedIdentifier reverse = new DoubleIndexedIdentifier(targetIds);
                int targetIndex = 0;
                for (final int length : targetLengths) {
                if (length != 0) {
                    System.out.printf("target-id %s: index: %d length=%d %n", reverse.getId(targetIndex), targetIndex,
                            length);
                }
                targetIndex++;
                }
                System.out.println("LastToCompact dumping targetLengths done ============== ");
                */
                writer.setTargetLengths(targetLengths.toIntArray(new int[targetLengths.size()]));
                if (readIndexFilter != null) {
                    writer.putStatistic("keep-filter-filename", readIndexFilterFile.getName());
                }
                writer.putStatistic("number-of-entries-written", numAligns);

                writer.setNumQueries(numberOfReads);
                writer.printStats(System.out);
                System.out.printf("Removed by quality filter: %d%n", removedByQualityFilter);
                System.out.printf("Not best score: %d%n", notBestScore);
            }
            progress.stop();
        }
    }

    // convert COUNTS to compact alignment
    if (!onlyMafFile) {
        assert new File(countsInputFile).exists() : "Missing COUNTS file: " + countsInputFile;

        System.out.println("Recording ambiguity-threshold=" + mParameter);
        System.out.println("Will import length of match.");

        for (final Map<String, String> line : new TsvLineIterator(countsInputFile)) {
            final int queryNameToIndex = Integer.parseInt(line.get("query-name"));
            final int depth = Integer.parseInt(line.get("depth"));
            final int count = Integer.parseInt(line.get("number-of-matches"));
            // TMH writer adds the alignment entry only if hits > thresh
            tmhWriter.append(queryNameToIndex, count, depth);
        }
    }

    return numAligns;
}

From source file:io.personium.engine.extension.support.ExtensionJarLoader.java

/**
 * ExtensionJarDirectory?? jar?URL??./*ww  w .j  a v  a 2  s  .  c  o m*/
 * ???? "jar"????
 * @param extJarDir Extensionjar??
 * @param searchDescend true: ?, false: ????
 * @return jar? URL.
 */
private List<URL> getJarPaths(Path extJarDir, boolean searchDescend) throws PersoniumEngineException {
    try {
        // ??
        List<URL> uriList = new ArrayList<URL>();
        // jar?????
        uriList.add(new URL("file", "", extJarDir.toFile().getAbsolutePath() + "/"));

        // jar?
        File[] jarFiles = extJarDir.toFile().listFiles(new FileFilter() {
            @Override
            public boolean accept(File pathname) {
                if (!pathname.exists() || !pathname.canRead() || pathname.isDirectory()) {
                    return false;
                }
                return FilenameUtils.isExtension(pathname.getName(), JAR_SUFFIX);
            }
        });

        if (null != jarFiles) {
            for (File jarFile : jarFiles) {
                try {
                    uriList.add(new URL("file", "", jarFile.getCanonicalPath()));
                    log.info(String.format("Info: Adding extension jar file %s to classloader.",
                            jarFile.toURI()));
                } catch (MalformedURLException e) {
                    // ############################################################################3
                    // ????????? jar???????? jar????
                    // ? Extension????????? Extension????? UserScript??
                    // ????????????
                    // ?? Extension?????Script???
                    // ############################################################################3
                    log.info(String.format("Warn: Some Extension jar file has malformed path. Ignoring: %s",
                            jarFile.toURI()));
                } catch (IOException e) {
                    log.info(String.format("Warn: Some Extension jar file has malformed path. Ignoring: %s",
                            jarFile.toURI()));
                }
            }
        }

        // ?
        File[] subDirs = extJarDir.toFile().listFiles(new FileFilter() {
            @Override
            public boolean accept(File pathname) {
                return pathname.exists() && pathname.isDirectory() && pathname.canRead();
            }
        });

        if (null != subDirs) {
            for (File subDir : subDirs) {
                //  jar?
                uriList.addAll(getJarPaths(subDir.toPath(), searchDescend));
            }
        }
        return uriList;
    } catch (RuntimeException e) {
        e.printStackTrace();
        log.info(String.format("Warn: Error occured while loading Extension: %s", e.getMessage()));
        throw new PersoniumEngineException("Error occured while loading Extension.",
                PersoniumEngineException.STATUSCODE_SERVER_ERROR, e);
    } catch (Exception e) {
        log.info(String.format("Warn: Error occured while loading Extension: %s", e.getMessage()));
        throw new PersoniumEngineException("Error occured while loading Extension.",
                PersoniumEngineException.STATUSCODE_SERVER_ERROR, e);
    }
}

From source file:com.gmail.frogocomics.schematic.gui.Main.java

@Override
public void start(Stage primaryStage) throws Exception {
    this.primaryStage = primaryStage;
    this.root = new GridPane();
    this.primaryScene = new Scene(this.root, 1000, 600, Color.AZURE);

    Label title = new Label("Schematic Utilities");
    title.setId("schematic-utilities");
    title.setPrefWidth(this.primaryScene.getWidth() + 500);
    this.root.add(title, 0, 0);

    filesSelected.setId("files-selected");
    this.root.add(filesSelected, 0, 1);

    Region spacer1 = new Region();
    spacer1.setPrefWidth(30);/*ww w. j av a2 s  . c  o m*/
    spacer1.setPrefHeight(30);

    Region spacer2 = new Region();
    spacer2.setPrefWidth(30);
    spacer2.setPrefHeight(30);

    Region spacer3 = new Region();
    spacer3.setPrefWidth(30);
    spacer3.setPrefHeight(250);

    Region spacer4 = new Region();
    spacer4.setPrefWidth(1000);
    spacer4.setPrefHeight(10);

    Region spacer5 = new Region();
    spacer5.setPrefWidth(30);
    spacer5.setPrefHeight(30);

    Region spacer6 = new Region();
    spacer6.setPrefWidth(1000);
    spacer6.setPrefHeight(10);

    Region spacer7 = new Region();
    spacer7.setPrefWidth(1000);
    spacer7.setPrefHeight(100);

    Region spacer8 = new Region();
    spacer8.setPrefWidth(30);
    spacer8.setPrefHeight(30);

    this.root.add(spacer4, 0, 3);

    listView.setId("schematic-list");
    listView.setEditable(false);
    listView.setPrefWidth(500);
    listView.setPrefHeight(250);
    this.root.add(new HBox(spacer3, listView), 0, 4);

    uploadFiles.setPadding(new Insets(5, 5, 5, 5));
    uploadFiles.setPrefWidth(120);
    uploadFiles.setPrefHeight(30);
    uploadFiles.setOnAction((event) -> {
        FileChooser fileChooser = new FileChooser();
        fileChooser.setTitle("Select schematic(s)");
        fileChooser.getExtensionFilters().addAll(
                new FileChooser.ExtensionFilter("MCEdit Schematic File", "*.schematic"),
                new FileChooser.ExtensionFilter("Biome World Object Version 2", "*.bo2"));
        List<File> selectedFiles = fileChooser.showOpenMultipleDialog(this.primaryStage);
        if (selectedFiles != null) {
            if (selectedFiles.size() == 1) {
                filesSelected.setText("There is currently 1 file selected");
            } else {
                filesSelected.setText(
                        "There are currently " + String.valueOf(selectedFiles.size()) + " files selected");
            }
            ObservableList<SchematicLocation> selectedSchematicFiles = FXCollections.observableArrayList();
            selectedSchematicFiles.addAll(selectedFiles.stream().map(f -> new SchematicLocation(f, f.getName()))
                    .collect(Collectors.toList()));
            listView.setItems(selectedSchematicFiles);
            this.schematics = selectedSchematicFiles;
        }

    });
    this.root.add(new HBox(spacer1, uploadFiles, spacer2,
            new Label("Only .schematic files are allowed at this point!")), 0, 2);

    editing.setPadding(new Insets(5, 5, 5, 5));
    editing.setPrefWidth(240);
    editing.setPrefHeight(30);
    editing.setDisable(true);
    editing.setOnAction(event -> this.primaryStage.setScene(Editing.getScene()));
    this.root.add(new HBox(spacer8, editing), 0, 8);

    loadSchematics.setPadding(new Insets(5, 5, 5, 5));
    loadSchematics.setPrefWidth(120);
    loadSchematics.setPrefHeight(30);
    loadSchematics.setOnAction(event -> {
        if (this.schematics != null) {
            ((Runnable) () -> {
                for (SchematicLocation location : this.schematics) {
                    if (FilenameUtils.isExtension(location.getLocation().getName(), "schematic")) {
                        try {
                            Schematics.schematics.add(McEditSchematicObject.load(location.getLocation()));
                        } catch (ParseException | ClassicNotSupportedException | IOException e) {
                            e.printStackTrace();
                        }
                    } else if (FilenameUtils.isExtension(location.getLocation().getName(), "bo2")) {
                        try {
                            Schematics.schematics.add(BiomeWorldV2Object.load(location.getLocation()));
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
                }
            }).run();
            loadSchematics.setDisable(true);
            uploadFiles.setDisable(true);
            listView.setDisable(true);
            editing.setDisable(false);
        }
    });
    this.root.add(spacer6, 0, 5);
    this.root.add(new HBox(spacer5, loadSchematics), 0, 6);
    this.root.add(spacer7, 0, 7);

    this.primaryScene.getStylesheets()
            .add("https://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700,800");
    this.primaryScene.getStylesheets().add(new File("style.css").toURI().toURL().toExternalForm());
    this.primaryStage.setScene(this.primaryScene);
    this.primaryStage.setResizable(false);
    this.primaryStage.setTitle("Schematic Utilities - by frogocomics");
    this.primaryStage.show();
}

From source file:com.pieframework.runtime.utils.ArtifactManager.java

private static String getArchivePath(List<File> flist) {

    if (!flist.isEmpty()) {
        if (flist.size() == 1 && flist.get(0).isFile()
                && FilenameUtils.isExtension(flist.get(0).getName(), "zip")) {
            return flist.get(0).getPath();
        }//from www . j a  v  a 2  s  .  co m
    }

    return null;
}

From source file:com.htmlhifive.tools.jslint.dialog.CreateOptionFileDialog.java

/**
 * ???./*from w ww . j  a  va  2 s  . c om*/
 */
private void initializeDataBindings() {
    DataBindingContext context = new DataBindingContext();
    // validator
    MultiValidator validator = new MultiValidator() {

        @Override
        protected IStatus validate() {
            StringBuilder sb = new StringBuilder();
            String optionFileName = (String) wvOptionFileName.getValue();
            if (StringUtils.isEmpty(optionFileName)) {
                sb.append(Messages.EM0009.format(Messages.DL0021.getText()));
            } else if (!FilenameUtils.isExtension(optionFileName, "xml")) {
                optionFileName += ".xml";
            }
            String outputDir = (String) wvOutpuDir.getValue();

            if (StringUtils.isEmpty(outputDir)) {
                sb.append(Messages.EM0009.format(Messages.DL0020.getText()));
            } else {
                IPath path = new Path(outputDir);
                if (!ResourcesPlugin.getWorkspace().getRoot().exists(path)) {
                    sb.append(Messages.EM0000.format(Messages.DL0020.getText()));
                }
            }

            if (StringUtils.isNotEmpty(optionFileName) && StringUtils.isNotEmpty(outputDir)) {
                IPath path = new Path(outputDir + "/" + optionFileName);
                if (ResourcesPlugin.getWorkspace().getRoot().exists(path)) {
                    sb.append(Messages.EM0013.getText());
                }
            }
            if (StringUtils.isEmpty(sb.toString())) {
                getButton(IDialogConstants.OK_ID).setEnabled(true);
                return ValidationStatus.info(Messages.DL0019.getText());
            }

            if (getButton(IDialogConstants.OK_ID) != null) {
                getButton(IDialogConstants.OK_ID).setEnabled(false);
            }
            return ValidationStatus.error(sb.toString());
        }
    };

    // 
    IObservableValue outputDir = SWTObservables.observeText(textOutputDir, SWT.Modify);
    context.bindValue(outputDir, wvOutpuDir, null, null);

    // ??
    IObservableValue optionFileName = SWTObservables.observeText(textOptionFileName, SWT.Modify);
    context.bindValue(optionFileName, wvOptionFileName, null, null);

    context.addValidationStatusProvider(validator);
    TitleAreaDialogSupport.create(this, context);

}

From source file:de.mprengemann.intellij.plugin.androidicons.settings.PluginSettings.java

private void scanForAndroidIconsAssets() {
    int colorCount = 0;
    int assetCount = 0;
    if (this.selectedAndroidIconsFile != null && this.selectedAndroidIconsFile.getCanonicalPath() != null) {
        File assetRoot = new File(this.selectedAndroidIconsFile.getCanonicalPath());
        final FilenameFilter folderFilter = new FilenameFilter() {
            @Override/* w  ww. jav a 2  s .co m*/
            public boolean accept(File file, String s) {
                return !s.startsWith(".") && new File(file, s).isDirectory();
            }
        };
        final FilenameFilter drawableFilter = new FilenameFilter() {
            @Override
            public boolean accept(File file, String s) {
                return FilenameUtils.isExtension(s, "png") && !(new File(file, s).isDirectory());
            }
        };
        File[] colorDirs = assetRoot.listFiles(folderFilter);
        if (colorDirs != null) {
            colorCount = colorDirs.length;
            if (colorDirs.length >= 1) {
                File exColorDir = colorDirs[0];
                File[] densities = exColorDir.listFiles(folderFilter);
                if (densities != null && densities.length >= 1) {
                    File exDensity = densities[0];
                    File[] assets = exDensity.listFiles(drawableFilter);
                    if (assets != null) {
                        assetCount = assets.length;
                    }
                }
            }
        }
    }
    androidIconsFoundColorsText.setText(colorCount + " colors");
    androidIconsFoundDrawablesText.setText(assetCount + " drawables per color");
}

From source file:eu.openanalytics.rsb.component.DirectoryDepositHandler.java

public void handleJob(final Message<File> message) throws IOException {
    final DepositDirectoryConfiguration depositDirectoryConfiguration = message.getHeaders()
            .get(DIRECTORY_CONFIG_HEADER_NAME, DepositDirectoryConfiguration.class);

    final String applicationName = depositDirectoryConfiguration.getApplicationName();
    final File dataFile = message.getPayload();

    final File depositRootDirectory = dataFile.getParentFile().getParentFile();
    final File acceptedDirectory = new File(depositRootDirectory, Configuration.DEPOSIT_ACCEPTED_SUBDIR);

    final File acceptedFile = new File(acceptedDirectory, dataFile.getName());
    FileUtils.deleteQuietly(acceptedFile); // in case a similar job already
                                           // exists
    FileUtils.moveFile(dataFile, acceptedFile);

    final Map<String, Serializable> meta = new HashMap<String, Serializable>();
    meta.put(DEPOSIT_ROOT_DIRECTORY_META_NAME, depositRootDirectory);
    meta.put(ORIGINAL_FILENAME_META_NAME, dataFile.getName());
    meta.put(INBOX_DIRECTORY_META_NAME, dataFile.getParent());

    final MultiFilesJob job = new MultiFilesJob(Source.DIRECTORY, applicationName, getUserName(),
            UUID.randomUUID(), (GregorianCalendar) GregorianCalendar.getInstance(), meta);

    try {//from w ww  .j  a v a2  s . c  o m
        if (FilenameUtils.isExtension(acceptedFile.getName().toLowerCase(), "zip")) {
            MultiFilesJob.addZipFilesToJob(new FileInputStream(acceptedFile), job);
        } else {
            MultiFilesJob.addDataToJob(new MimetypesFileTypeMap().getContentType(acceptedFile),
                    acceptedFile.getName(), new FileInputStream(acceptedFile), job);
        }

        final String jobConfigurationFileName = depositDirectoryConfiguration.getJobConfigurationFileName();

        if (StringUtils.isNotBlank(jobConfigurationFileName)) {
            final File jobConfigurationFile = getJobConfigurationFile(applicationName,
                    jobConfigurationFileName);

            job.addFile(Constants.MULTIPLE_FILES_JOB_CONFIGURATION, new FileInputStream(jobConfigurationFile));
        }

        getMessageDispatcher().dispatch(job);
    } catch (final Exception e) {
        final MultiFilesResult errorResult = job.buildErrorResult(e, getMessages());
        handleResult(errorResult);
    }
}

From source file:com.pieframework.runtime.utils.azure.Cspack.java

private void stageRoleBinaries(Role role, File roleDir) {
    File roleBin = null;/*from   w w w .j  a  v  a 2 s.co  m*/
    if (role.getProps().get("type") != null) {
        roleBin = new File(roleDir.getPath() + File.separatorChar);
        roleBin.mkdir();

        if (roleBin != null) {
            for (String key : role.getChildren().keySet()) {

                if (role.getChildren().get(key) instanceof Service) {
                    Service s = (Service) role.getChildren().get(key);
                    if (s.getProps().get("type") != null
                            && s.getProps().get("type").equalsIgnoreCase("application")) {
                        String query = s.getProps().get("package");
                        if (query != null) {
                            String fQuery = s.getProps().get("package");
                            String nQuery = ResourceLoader.getResourceName(fQuery);
                            String pQuery = ResourceLoader.getResourcePath(fQuery);
                            Files bootstrap = (Files) s.getResources().get(nQuery);
                            if (bootstrap != null) {
                                List<File> flist = ResourceLoader.findPath(bootstrap.getLocalPath(), pQuery);
                                if (flist.size() == 1 && flist.get(0).exists()
                                        && FilenameUtils.isExtension(flist.get(0).getPath(), "zip")) {

                                    try {
                                        Zipper.unzip(flist.get(0).getPath(), roleBin.getPath());
                                        if (role.getProps().get("type").equals("WebRole")) {
                                            //Cleanup non-bin files
                                            for (File f : roleBin.listFiles()) {
                                                if (!f.getName().equalsIgnoreCase("bin")) {
                                                    FileUtils.forceDelete(f);
                                                }
                                            }

                                            //Move contents of bin dir into the current directory
                                            File binDir = new File(
                                                    roleBin.getPath() + File.separatorChar + "bin");
                                            if (binDir.exists()) {
                                                for (File f : binDir.listFiles()) {
                                                    if (f.isDirectory()) {
                                                        FileUtils.copyDirectory(f, roleBin);
                                                    } else {
                                                        FileUtils.copyFileToDirectory(f, roleBin);
                                                    }
                                                }
                                                FileUtils.forceDelete(binDir);
                                            }
                                        }
                                    } catch (ZipException e) {
                                        // TODO Auto-generated catch block
                                        e.printStackTrace();
                                    } catch (IOException e) {
                                        // TODO Auto-generated catch block
                                        e.printStackTrace();
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

From source file:edu.ku.brc.specify.config.init.TaxonLoadSetupPanel.java

@Override
public void getValues(final Properties props) {
    String fileName = otherTF.getText();
    if (fileName.isEmpty()) {
        TaxonFileDesc tfd = (TaxonFileDesc) fileCBX.getSelectedItem();
        if (tfd != null && FilenameUtils.isExtension(tfd.getFileName().toLowerCase(), XLS)) {
            fileName = tfd.getFileName();
        }/*  w  w  w  .ja  va  2 s  .c o  m*/
    }

    if (!otherTF.getText().isEmpty() || StringUtils.isNotEmpty(fileName)) {
        props.put("othertaxonfile", !otherTF.getText().isEmpty());
        props.put("taxonfilename", fileName != null ? fileName : "");
        props.put("preloadtaxon", preloadChk.isSelected());
    }
}

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

private void fillAssets() {
    assetSpinner.removeAllItems();// w w  w  .j  a va2s .  c  o  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 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_") && filename.endsWith("_black_48dp");
        }
    };
    File[] assets = assetRoot.listFiles(drawableFileNameFiler);
    if (assets == null) {
        return;
    }
    for (File asset : assets) {
        String assetName = FilenameUtils.removeExtension(asset.getName());
        assetName = assetName.replace("_black_48dp", "");
        assetName = assetName.replace("ic_", "");
        assetSpinner.addItem(assetName);
    }
}