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

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

Introduction

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

Prototype

public static String concat(String basePath, String fullFilenameToAdd) 

Source Link

Document

Concatenates a filename to a base path using normal command line style rules.

Usage

From source file:edu.cornell.med.icb.goby.readers.sam.TestGobyPaperTop5000s.java

/**
 * Setup the filenames for a RoundTripAlignment in a standard fashion for the 5000 tests.
 * @param input the input sam/bam filename. Should end with .sam, .bam, or .sam.gz
 * @return a RoundTripAlignment with input and output filenames configured
 *///from   w w w . j  a  va 2  s .  c o m
private RoundTripAlignment setupRoundTrip(final String input) {
    final String basename;
    if (input.toLowerCase().endsWith(".gz")) {
        basename = FilenameUtils.getBaseName(FilenameUtils.getBaseName(input));
    } else {
        basename = FilenameUtils.getBaseName(input);
    }
    final RoundTripAlignment rtc = new RoundTripAlignment();
    rtc.sourceBamFilename = FilenameUtils.concat(BASE_TEST_INPUT_DIR, input);
    rtc.destGobyBasename = FilenameUtils.concat(BASE_TEST_OUTPUT_DIR, basename);
    rtc.destBamFilename = FilenameUtils.concat(BASE_TEST_OUTPUT_DIR, basename + ".sam");
    return rtc;
}

From source file:com.enioka.jqm.tools.MulticastPrintStream.java

void registerThread(String fileName) {
    try {/*w  w w .  jav  a  2s.c om*/
        unregisterThread();
        Writer w = new FileWriter(FilenameUtils.concat(rootLogDir, fileName), true);
        logger.set(new BufferedWriter(w));
    } catch (IOException e) {
        // A PrintStream is supposed to never throw IOException
        jqmlogger.warn("could not register specific logger for a thread. Stdout will be used instead.", e);
    }
}

From source file:net.bpelunit.framework.base.BPELUnitBaseRunner.java

@Override
public void configureDeployers() throws ConfigurationException {
    String deploymentConfigFile = FilenameUtils.concat(fHomeDirectory,
            FilenameUtils.concat(CONFIG_DIR, DEPLOYER_CONFIG_FILE_NAME));

    if ((deploymentConfigFile != null) && (new File(deploymentConfigFile).exists())) {
        try {//from  w  w w .j  a v  a 2  s .  c  o  m
            ExtensionRegistry.loadDeploymentConfiguration(new File(deploymentConfigFile).toURI().toURL());
        } catch (MalformedURLException e) {
            throw new ConfigurationException(
                    "BPELUnit could not locate the deployer config file: " + deploymentConfigFile, e);
        }
    } else {
        // if file could not be loaded, default to embedded settings
        ExtensionRegistry.loadDeploymentConfiguration(
                this.getClass().getResource('/' + CONFIG_DIR + '/' + DEPLOYER_CONFIG_FILE_NAME));
    }
}

From source file:edu.cornell.med.icb.goby.alignments.TestReadWriteAlignments.java

@Test
public void readWriteEntries101() throws IOException {
    final AlignmentWriterImpl writer = new AlignmentWriterImpl(
            FilenameUtils.concat(BASE_TEST_DIR, "align-101"));
    writer.setNumAlignmentEntriesPerChunk(1000);
    final int numReads = 2000;
    final int numTargets = 10;
    int numExpected = 0;
    int position = 1;
    for (int referenceIndex = 0; referenceIndex < numTargets; referenceIndex++) {
        for (int queryIndex = 0; queryIndex < numReads; queryIndex++) {
            writer.setAlignmentEntry(queryIndex, referenceIndex, position++, 30, false, constantQueryLength);
            writer.appendEntry();//from   w w w  .j  a va  2s. c  o  m
            numExpected++;
        }
    }

    writer.close();
    writer.printStats(System.out);

    int count = 0;
    final AlignmentReader reader = new AlignmentReaderImpl(FilenameUtils.concat(BASE_TEST_DIR, "align-101"));
    int maxQueryIndex = -1;
    int maxTargetIndex = -1;
    reader.readHeader();
    while (reader.hasNext()) {
        final Alignments.AlignmentEntry alignmentEntry = reader.next();
        assert alignmentEntry.hasPosition();
        maxQueryIndex = Math.max(maxQueryIndex, alignmentEntry.getQueryIndex());
        maxTargetIndex = Math.max(maxTargetIndex, alignmentEntry.getTargetIndex());
        count++;
    }
    assertEquals(numExpected, count);
    assertEquals("number of queries must match", numReads - 1, maxQueryIndex);
    assertEquals("number of targets must match", numTargets - 1, maxTargetIndex);

}

From source file:com.gemstone.gemfire.management.internal.configuration.ZipUtilsJUnitTest.java

@Test
public void testZipUtils() throws Exception {
    File sf = new File(sourceFolderName);
    File cf = new File(FilenameUtils.concat(sourceFolderName, clusterFolderName));
    File gf = new File(FilenameUtils.concat(sourceFolderName, groupFolderName));
    sf.mkdir();//from ww  w. j  ava  2 s. c  om
    cf.mkdir();
    gf.mkdir();
    FileUtils.writeStringToFile(new File(FilenameUtils.concat(cf.getCanonicalPath(), clusterTextFileName)),
            clusterText);
    FileUtils.writeStringToFile(new File(FilenameUtils.concat(gf.getCanonicalPath(), groupTextFileName)),
            groupText);
    ZipUtils.zip(sourceFolderName, zipFileName);
    File zipFile = new File(zipFileName);
    assertTrue(zipFile.exists());
    assertTrue(zipFile.isFile());
    ZipUtils.unzip(zipFileName, destinationFolderName);

    File df = new File(destinationFolderName);
    assertTrue(df.exists());
    assertTrue(df.isDirectory());

    File[] subDirs = df.listFiles();
    assertTrue((subDirs != null) && (subDirs.length != 0));
    File dfClusterTextFile = new File(FilenameUtils.concat(destinationFolderName,
            clusterFolderName + File.separator + clusterTextFileName));
    File dfGroupTextFile = new File(
            FilenameUtils.concat(destinationFolderName, groupFolderName + File.separator + groupTextFileName));

    assertTrue(clusterText.equals(FileUtils.readFileToString(dfClusterTextFile)));
    assertTrue(groupText.equals(FileUtils.readFileToString(dfGroupTextFile)));
}

From source file:edu.cornell.med.icb.goby.stats.TestStatsWriter.java

@Test
public void testVCF() throws IOException {

    final String file = FilenameUtils.concat(BASE_TEST_DIR, "1.vcf");

    VCFWriter writer = new VCFWriter(new PrintWriter(new FileWriter(file)));

    int fieldC = writer.defineField("INFO", "C", 1, ColumnType.String, "something about C");
    int fieldD = writer.defineField("INFO", "D", 1, ColumnType.String, "something about D");

    writer.writeHeader();/* w w w. jav  a2  s .  c o  m*/
    writer.setInfo(fieldC, "1");
    writer.setInfo(fieldD, "dvalue");
    writer.writeRecord();
    writer.close();

    assertEquals(new File("test-data/stats-writer/1.vcf"), new File("test-results/stats-writer/1.vcf"));
}

From source file:com.redhat.victims.VictimsResultCache.java

public VictimsResultCache() throws VictimsException {
    location = FilenameUtils.concat(VictimsConfig.home().toString(), CACHE_NAME);
    File cache = new File(location);
    if (!cache.exists()) {
        create(cache);//from w  w  w .  ja  va2 s .c om
    } else if (VictimsConfig.purgeCache() && !purged) {
        purge();
        // make sure that another instance does not purge again
        purged = true;
    }
}

From source file:ddf.content.plugin.video.TestVideoThumbnailPlugin.java

@Before
public void setUp() throws IOException, MimeTypeParseException, URISyntaxException {
    System.setProperty("ddf.home", SystemUtils.USER_DIR);

    binaryPath = FilenameUtils.concat(System.getProperty("ddf.home"), "bin_third_party");

    setUpMockBundleContext();/*ww  w  .  j a v  a 2 s  . c o  m*/

    videoThumbnailPlugin = new VideoThumbnailPlugin(mockBundleContext);
}

From source file:net.sf.jvifm.util.AutoCompleteUtil.java

public static List<File> getFileCompleteList(String pwd, String path, boolean onlyDir) {
    List<File> list = new ArrayList<File>();
    String fileName = new File(path).getName();

    if (path.endsWith(":"))
        return null;

    File file = new File(FilenameUtils.concat(pwd, path));

    File pwdFile = null;//  w  ww.  j  av a 2 s .c  o  m
    pwdFile = file;
    if (path.endsWith(File.separator) || path.trim().equals("")) {
        pwdFile = file;
    } else {
        if (file.getParent() == null)
            return null;
        pwdFile = new File(file.getParent());
    }
    if (!pwdFile.exists())
        return null;
    File[] files = pwdFile.listFiles((FileFilter) Util.getDefaultFileFilter());

    if (files == null || files.length <= 0)
        return null;
    boolean lowerCase = false;
    if (fileName.toLowerCase().equals(fileName)) {
        lowerCase = true;
    }
    for (int i = 0; i < files.length; i++) {
        String tmpFileName = files[i].getName();
        if (lowerCase)
            tmpFileName = tmpFileName.toLowerCase();
        if (tmpFileName.startsWith(fileName) || path.endsWith(File.separator)
                || FilenameUtils.wildcardMatch(tmpFileName, fileName, IOCase.INSENSITIVE))
            if (onlyDir) {
                if (files[i].isDirectory())
                    list.add(files[i]);
            } else {
                list.add(files[i]);
            }
    }
    if (list.size() <= 0)
        return null;
    return list;
}

From source file:fr.mby.portal.coreimpl.configuration.PropertiesConfigurationManager.java

@Override
public PropertiesConfiguration initConfiguration(final String key, final Class<?> valueType, final String tag)
        throws IllegalArgumentException, ConfigurationException {
    Assert.hasText(key, "No key provided !");
    if (this.configurationByKey.containsKey(key)) {
        throw new IllegalArgumentException("Configuration element already initialized for key: " + key + " !");
    }//from   www.  j  ava  2 s.  c  o m
    Assert.notNull(valueType, "No value type provided !");
    Assert.hasText(tag, "No tag provided !");

    final String propertiesFileName = FilenameUtils.concat(this.configFileDirectory, key + ".properties");
    final File propertiesFile = new File(propertiesFileName);
    final PropertiesConfiguration config = new PropertiesConfiguration(propertiesFile);
    this.configurationByKey.put(key, config);
    this.valueTypeByKey.put(key, valueType);

    this.tagConfigurationKey(key, tag);

    return config;
}