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

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

Introduction

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

Prototype

public static String removeExtension(String filename) 

Source Link

Document

Removes the extension from a filename.

Usage

From source file:dmh.kuebiko.view.ImageManagerTest.java

/**
 * Retrieve a list of all known image ID strings of a particular size.
 * @param size The size of the requested images.
 * @return A list of valid image IDs.//from   w w  w .  jav  a 2 s .c  o  m
 */
private Collection<String> getImageIds(ImageSize size) throws URISyntaxException {
    String path = String.format("images/%s/", size.toString().toLowerCase());
    File imageDir = new File(getClass().getResource(path).toURI());

    Collection<String> imageIds = Lists.newArrayList(
            Collections2.transform(Arrays.asList(imageDir.list()), new Function<String, String>() {
                @Override
                public String apply(String input) {
                    return "png".equals(FilenameUtils.getExtension(input))
                            ? FilenameUtils.removeExtension(input)
                            : "";
                }
            }));
    imageIds.removeAll(Collections.singleton(""));

    return imageIds;
}

From source file:io.github.bluemarlin.ui.searchtree.SearchTreeItem.java

public SearchTreeItem(File file) {
    this.file = file;
    searchRunning.bind(searchService.runningProperty());
    search.bind(searchService.searchProperty());

    displayName.bind(Bindings.createStringBinding(() -> {
        String name = FilenameUtils.removeExtension(file.getName());
        Search value = search.getValue();
        if (value != null) {
            name += " (" + value.getSearchResult().getTotal() + ")";
            if (value.getSearchResult().getTotal() > 0) {
                if (fromDurianSearch.getValue()) {
                    name = "! " + name;
                }/*from   ww w .ja  va2s. co m*/
            }
        }
        return name;
    }, search, fromDurianSearch));

    searchService.setOnFailed(e -> searchService.getException().printStackTrace());
}

From source file:it.zielke.a2pdf.Anki2PDF.java

/**
 * Get a filename of the actual output file based on the current side. If
 * the user specified filename is "C:/anki.pdf", then the resulting output
 * file will either be "C:/anki_0.pdf" or "C:/anki_1.pdf" based on the
 * current side./*  ww  w  .jav  a2s  .  com*/
 * 
 * @param side
 *            current side, 0: front side, 1: back side.
 * @return resulting file name
 */
private File getCurrentOutputFile(int side) {
    return new File(String.format("%s_%s.pdf",
            FilenameUtils.removeExtension(this.settings.getOutputFile().getAbsolutePath()), side));
}

From source file:ch.unibas.fittingwizard.infrastructure.RealBabelScript.java

private String getMoleculeName(File input) {
    return FilenameUtils.removeExtension(input.getName());
}

From source file:jease.cms.web.content.editor.TransitEditor.java

private void pathSelected() {
    String pathname = (String) uri.getValue();
    if (StringUtils.isNotBlank(pathname)) {
        String name = FilenameUtils.getName(pathname);
        if (StringUtils.isEmpty(id.getValue())) {
            id.setText(name);// w  w w  . j  a  v a 2  s.  c  o  m
        }
        if (StringUtils.isEmpty(title.getValue())) {
            title.setText(FilenameUtils.removeExtension(name));
        }
    }
}

From source file:de.nbi.ontology.test.OntologyIndexTest.java

/**
 * Test, if concept labels are created properly. The input file contains a
 * URI in each line./*from ww  w  .  ja va  2 s .  com*/
 * 
 * @param inFile
 *            an ontology
 * @throws IOException
 */
//   @Test(dataProviderClass=OntologyDataProvider.class, dataProvider="indexTestFiles",
//         groups = {"functest"})
public void createIndex(File inFile) throws IOException {
    log.info("Processing " + inFile.getName());
    String basename = FilenameUtils.removeExtension(inFile.getAbsolutePath());
    File outFile = new File(basename + ".out");
    File resFile = new File(basename + ".res");

    index.reset();
    index.load(new FileInputStream(inFile));

    PrintWriter w = new PrintWriter(new FileWriter(outFile));
    Map<String, OntClass[]> labelIdx = index.getLabelIndex();
    for (String k : labelIdx.keySet()) {
        w.println(k + " = > " + Arrays.toString(labelIdx.get(k)));
    }

    List<String> prefixIdx = new ArrayList<String>(index.getPrefixIndex());
    Collections.sort(prefixIdx);
    for (String p : prefixIdx) {
        w.println(p);
    }
    w.flush();
    w.close();

    Assert.assertTrue(FileUtils.contentEquals(outFile, resFile));
}

From source file:de.nbi.ontology.test.TextEnhancerTest.java

/**
 * Test, if texts are enhances properly.
 * //from   w  w w .  j a va  2s  .c om
 * @param inFile
 *            a text
 * @throws IOException
 */
@Test(dataProviderClass = TestFileProvider.class, dataProvider = "enhanceTestFiles", groups = { "functest" })
public void exactMatch(File inFile) throws IOException {
    log.info("Processing " + inFile.getName());
    String basename = FilenameUtils.removeExtension(inFile.getAbsolutePath());
    File outFile = new File(basename + ".out");
    File resFile = new File(basename + ".res");

    PrintWriter w = new PrintWriter(new FileWriter(outFile));

    XWikiTextEnhancer enhancer = new XWikiTextEnhancer();
    String text = FileUtils.readFileToString(inFile);
    String newText = enhancer.enhance(text);

    w.print(newText);
    w.flush();
    w.close();

    Assert.assertTrue(FileUtils.contentEquals(outFile, resFile));
}

From source file:ch.mlutz.plugins.t4e.tapestry.element.TapestryHtmlElement.java

@Override
public String getName() {
    return FilenameUtils.removeExtension(htmlFile.getName());
}

From source file:de.uzk.hki.da.format.PublishCLIConversionStrategy.java

@Override
public List<Event> convertFile(ConversionInstruction ci) throws FileNotFoundException {
    if (pkg == null)
        throw new IllegalStateException("Package not set");

    List<Event> results = new ArrayList<Event>();

    for (String audience : audiences) {

        String audience_lc = audience.toLowerCase();
        String repName = "dip/" + audience_lc;

        Path.make(object.getDataPath(), repName, ci.getTarget_folder()).toFile().mkdirs();

        String[] commandAsArray = assemble(ci, repName);
        if (!cliConnector.execute(commandAsArray))
            throw new RuntimeException("convert did not succeed");

        String targetSuffix = ci.getConversion_routine().getTarget_suffix();
        if (targetSuffix.equals("*"))
            targetSuffix = FilenameUtils.getExtension(ci.getSource_file().toRegularFile().getAbsolutePath());
        DAFile result = new DAFile(pkg, repName,
                ci.getTarget_folder() + "/"
                        + FilenameUtils.removeExtension(Matcher.quoteReplacement(
                                FilenameUtils.getName(ci.getSource_file().toRegularFile().getAbsolutePath())))
                        + "." + targetSuffix);

        Event e = new Event();
        e.setType("CONVERT");
        e.setDetail(Utilities.createString(commandAsArray));
        e.setSource_file(ci.getSource_file());
        e.setTarget_file(result);/*from   w w  w .j a  v  a  2 s  . c  o m*/
        e.setDate(new Date());

        results.add(e);

    }

    return results;

}

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

/**
 * Configure./* w w w.  j a  v a2  s .  co  m*/
 *
 * @param args command line arguments
 * @return this object for chaining
 * @throws IOException error parsing
 * @throws JSAPException error parsing
 */
@Override
public AbstractCommandLineMode configure(final String[] args) throws IOException, JSAPException {
    final JSAPResult jsapResult = parseJsapArguments(args);

    inputFile = jsapResult.getString("input");
    basename = jsapResult.getString("basename");
    if (basename == null) {
        String filename = inputFile;
        if (filename.endsWith(".gz")) {
            // remove the .gz before removing the next extension
            // this is done so that file.fasta.gz results in basename=file.
            filename = FilenameUtils.removeExtension(filename);
        }
        basename = FilenameUtils.removeExtension(filename);
        System.out.printf("Automatically determined basename=%s, please use --basename if you prefer "
                + "different output filenames.%n", basename);
    }
    return this;
}