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:net.certiv.antlr.project.util.Strings.java

/**
 * Concats the arguments to produce a filesystem path fragment. Separators are added as needed.
 * All separators are converted to standard separators, ie, *nix-style.
 *//*from   w w  w . jav a2  s  .  c  om*/
public static String concat(String... args) {
    String result = "";
    for (String arg : args) {
        result = FilenameUtils.concat(result, arg);
    }
    return result;
}

From source file:edu.kit.dama.staging.util.StagingUtils.java

/**
 * Get the temporary directory all transfers. This directory is located in the
 * user home directory under ~/.lsdf/. Within the temporary directory the
 * transfer can store status information or checkpoint data to be able to
 * resume failed transfers.//from ww  w.j  a  va2 s. c o m
 *
 * @return The transfers temporary directory
 *
 * @throws IOException If there was not set any TID for this transfer or if
 * there are problems getting the user's home directory
 */
public static String getTempDir() throws IOException {
    File userHome = SystemUtils.getUserHome();
    if (userHome == null || !userHome.isDirectory() || !userHome.canRead() || !userHome.canWrite()) {
        throw new IOException("Invalid user home directory '" + userHome + "'");
    }
    return FilenameUtils.concat(userHome.getCanonicalPath(), ".lsdf");
}

From source file:jp.co.opentone.bsol.linkbinder.util.AttachmentUtil.java

/**
 * ?????./*from  www  .  ja  v  a 2s. c  o m*/
 * @param randomId ?????????
 * @param baseName ?????. ?????
 * @return ?????
 */
public static String createFileName(String randomId, String baseName) {
    return FilenameUtils.concat(getRoot().getAbsolutePath(),
            String.format(FORMAT_FILE_NAME, randomId, HashUtil.getRandomString(randomId), baseName));
}

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

@Test
public void testAllEntries() throws IOException {
    final String basename = "align-position-slices-0";
    buildAlignment(basename);/*from   ww  w  .j a v a  2s.c  o  m*/

    { // check that we can read everything when the boundaries include everything:
        final AlignmentReader reader = new AlignmentReaderImpl(FilenameUtils.concat(BASE_TEST_DIR, basename), 0,
                400, 4, 500);

        check(reader, 1, 12);
        check(reader, 1, 13);
        check(reader, 1, 13);
        check(reader, 1, 13);
        check(reader, 2, 123);
        check(reader, 2, 300);
        check(reader, 2, 300);
        reader.close();
    }
}

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

@Test
public void testFewSkips1() throws IOException {
    final String basename = "align-skip-to-1";
    final AlignmentWriterImpl writer = new AlignmentWriterImpl(FilenameUtils.concat(BASE_TEST_DIR, basename));
    writer.setNumAlignmentEntriesPerChunk(numEntriesPerChunk);

    final int numTargets = 3;
    final int[] targetLengths = new int[numTargets];

    for (int referenceIndex = 0; referenceIndex < numTargets; referenceIndex++) {
        targetLengths[referenceIndex] = 1000;
    }//from   w w w. j a va2 s  . co m
    writer.setTargetLengths(targetLengths);
    // we write this alignment sorted:

    writer.setSorted(true);

    writer.setAlignmentEntry(0, 1, 12, 30, false, constantQueryLength);
    writer.appendEntry();

    writer.setAlignmentEntry(0, 1, 13, 30, false, constantQueryLength);
    writer.appendEntry();

    writer.setAlignmentEntry(0, 1, 13, 30, false, constantQueryLength);
    writer.appendEntry();

    writer.setAlignmentEntry(0, 2, 123, 30, false, constantQueryLength);
    writer.appendEntry();
    writer.setAlignmentEntry(0, 2, 300, 30, false, constantQueryLength);
    writer.appendEntry();
    writer.setAlignmentEntry(0, 2, 300, 30, false, constantQueryLength);
    writer.appendEntry();
    writer.close();
    writer.printStats(System.out);

    final AlignmentReader reader = new AlignmentReaderImpl(FilenameUtils.concat(BASE_TEST_DIR, basename));

    final Alignments.AlignmentEntry a = reader.skipTo(0, 0);
    assertNotNull(a);
    assertEquals(1, a.getTargetIndex());
    assertEquals(12, a.getPosition());
    final Alignments.AlignmentEntry b = reader.skipTo(0, 0);
    assertEquals(1, b.getTargetIndex());
    assertEquals(13, b.getPosition());

    final Alignments.AlignmentEntry c = reader.skipTo(0, 0);
    assertEquals(1, c.getTargetIndex());
    assertEquals(13, c.getPosition());

    final Alignments.AlignmentEntry d = reader.skipTo(2, 300);
    assertEquals(2, d.getTargetIndex());
    assertEquals(300, d.getPosition());

    final Alignments.AlignmentEntry e = reader.skipTo(2, 300);
    assertEquals(2, e.getTargetIndex());
    assertEquals(300, e.getPosition());
    assertFalse(reader.hasNext());

}

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

@Test
public void testMerge() throws IOException {
    Merge merger = new Merge(3);

    List<File> inputFiles = new ArrayList<File>();
    inputFiles.add(new File(FilenameUtils.concat(BASE_TEST_DIR, "align-101")));

    String outputFile = FilenameUtils.concat(BASE_TEST_DIR, "out-101-merged");
    merger.setK(2);/*from ww w .  ja  v  a  2  s. c o m*/
    merger.merge(inputFiles, outputFile);

    // With k=2 and a single input file, the merge should keep only the best score for each query:
    String basename = outputFile;
    int count = countAlignmentEntries(basename);
    assertEquals(numQueries101, count);

    merger = new Merge(3);

    inputFiles = new ArrayList<File>();
    inputFiles.add(new File(FilenameUtils.concat(BASE_TEST_DIR, "align-101")));
    inputFiles.add(new File(FilenameUtils.concat(BASE_TEST_DIR, "align-101")));

    outputFile = FilenameUtils.concat(BASE_TEST_DIR, "out-102-merged");
    merger.setK(1);
    merger.merge(inputFiles, outputFile);

    // With k=1 and twice the same input file, the merge should keep zero entries
    basename = outputFile;
    count = countAlignmentEntries(basename);
    assertEquals(0, count);
}

From source file:com.mbrlabs.mundus.core.RuntimeExporter.java

public static void export(KryoManager kryoManager, ProjectContext projectContext, FileHandle destFolder,
        boolean prettyPrint) throws IOException {
    ProjectDTO dto = new ProjectDTO();
    dto.setName(projectContext.name);//w ww  .j av  a2  s.co  m

    // models
    ModelDTO[] models = new ModelDTO[projectContext.models.size];
    for (int i = 0; i < models.length; i++) {
        models[i] = convert(projectContext.models.get(i));
    }
    dto.setModels(models);

    // terrains
    TerrainDTO[] terrains = new TerrainDTO[projectContext.terrains.size];
    for (int i = 0; i < terrains.length; i++) {
        terrains[i] = convert(projectContext.terrains.get(i));
    }
    dto.setTerrains(terrains);

    // textures
    TextureDTO[] textures = new TextureDTO[projectContext.textures.size];
    for (int i = 0; i < textures.length; i++) {
        textures[i] = convert(projectContext.textures.get(i));
    }
    dto.setTextures(textures);

    // scenes
    SceneDTO[] scenes = new SceneDTO[projectContext.scenes.size];
    for (int i = 0; i < scenes.length; i++) {
        String name = projectContext.scenes.get(i);
        Scene scene = DescriptorConverter.convert(kryoManager.loadScene(projectContext, name),
                projectContext.terrains, projectContext.models);
        scenes[i] = convert(scene);
    }
    dto.setScenes(scenes);

    // write JSON
    if (!destFolder.exists()) {
        destFolder.mkdirs();
    }
    FileHandle jsonOutput = Gdx.files.absolute(FilenameUtils.concat(destFolder.path(), "mundus"));
    OutputStream outputStream = new FileOutputStream(jsonOutput.path());
    Json json = new Json();
    json.setOutputType(JsonWriter.OutputType.json);
    String output = prettyPrint ? json.prettyPrint(dto) : json.toJson(dto);
    IOUtils.write(output, outputStream);

    // copy assets
    FileHandle assetOutput = Gdx.files.absolute(FilenameUtils.concat(destFolder.path(), "assets"));
    Gdx.files.absolute(FilenameUtils.concat(projectContext.path, "assets")).copyTo(assetOutput);
}

From source file:au.org.ala.delta.editor.directives.DirectivesFileExporter.java

/**
 * Creates a file in the supplied path on the file system to export the contents of the supplied
 * DirectivesFile.  If there is an existing file with the same name, it will be backed up and deleted.
 * @param file the DirectiveFile to be exported.
 * @param directoryPath the directory in which the file should be created.
 * @return a File to which the directives can be written.
 *//*  w w  w .ja va  2 s  .c  o  m*/
public File createExportFile(DirectiveFile file, String directoryPath) {
    String fileName = file.getShortFileName();
    FileUtils.backupAndDelete(fileName, directoryPath);

    FilenameUtils.concat(directoryPath, fileName);
    File directivesFile = new File(directoryPath + fileName);

    return directivesFile;
}

From source file:net.sf.jvifm.control.CopyCommand.java

public void execute() throws Exception {

    if (files == null || files.length <= 0)
        return;//from w w w  .ja v a  2s  .  c  o  m

    for (int i = 0; i < files.length; i++) {

        String src = FilenameUtils.concat(srcDir, files[i]);
        strValue = "";
        if (fileModelManager.isDestFileExisted(src, dstDir)) {
            if (yesToAll) {
                doFileOperator(src, dstDir, files[i]);
            } else if (noToAll) {
                continue;
            } else {

                File srcFile = new File(src);
                File dstFile = new File(FilenameUtils.concat(dstDir, srcFile.getName()));
                String srcSize = StringUtil.formatSize(srcFile.length());
                String srcDate = StringUtil.formatDate(srcFile.lastModified());
                String dstSize = StringUtil.formatSize(dstFile.length());
                String dstDate = StringUtil.formatDate(dstFile.lastModified());

                String msg = "";
                if (srcFile.isDirectory()) {
                    msg = msgFolderReplace;
                } else {
                    msg = msgFileReplace;
                }

                msg = msg.replaceAll("\\$name", srcFile.getName());
                msg = msg.replaceAll("\\$srcSize", srcSize);
                msg = msg.replaceAll("\\$srcDate", srcDate);
                msg = msg.replaceAll("\\$dstSize", dstSize);
                msg = msg.replaceAll("\\$dstDate", dstDate);
                strValue = new Util().openConfirmWindow(options, msgCpConfirmDlgTitle, msg, OptionShell.WARN);

                if (strValue == null || strValue.equals(msgOptionCancel))
                    return;

                if (strValue.equals(msgOptionYesToAll)) {
                    yesToAll = true;
                    doFileOperator(src, dstDir, files[i]);
                }

                if (strValue.equals(msgOptionNoToAll))
                    noToAll = true;
                if (strValue.equals(msgOptionNo))
                    continue;
                if (strValue.equals(msgOptionYes))
                    doFileOperator(src, dstDir, files[i]);
            }
        } else {
            doFileOperator(src, dstDir, files[i]);
        }
    }

}

From source file:com.perceptive.epm.perkolcentral.bl.ImageNowLicenseBL.java

@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.SERIALIZABLE, rollbackFor = ExceptionWrapper.class)
public void addImageNowLicenseRequest(Imagenowlicenses imagenowlicenses, String groupRequestedFor,
        String employeeUIDWhoRequestedLicense, File sysfpFile, String originalFileName)
        throws ExceptionWrapper {
    try {//from   ww  w.  java  2  s  .co m
        imageNowLicenseDataAccessor.addImageNowLicense(imagenowlicenses, groupRequestedFor,
                employeeUIDWhoRequestedLicense);
        if (!new File(fileUploadPath).exists())
            FileUtils.forceMkdir(new File(fileUploadPath));
        File filePathForThisRequest = new File(
                FilenameUtils.concat(fileUploadPath, imagenowlicenses.getImageNowLicenseRequestId()));
        FileUtils.forceMkdir(filePathForThisRequest);
        File fileNameToCopy = new File(
                FilenameUtils.concat(filePathForThisRequest.getAbsolutePath(), originalFileName));
        FileUtils.copyFile(sysfpFile, fileNameToCopy);
        //Send the email
        String messageToSend = String.format(Constants.email_license_request,
                imagenowlicenses.getEmployeeByRequestedByEmployeeId().getEmployeeName(),
                imagenowlicenses.getGroups().getGroupName(),
                new SimpleDateFormat("dd-MMM-yyyy").format(imagenowlicenses.getLicenseRequestedOn()),
                imagenowlicenses.getImageNowVersion(), imagenowlicenses.getHostname(),
                Long.toString(imagenowlicenses.getNumberOfLicenses()));
        email = new HtmlEmail();
        email.setHostName(emailHost);
        email.setHtmlMsg(messageToSend);
        email.setSubject("ImageNow License Request");
        //email.setFrom("ImageNowLicenseRequest@perceptivesoftware.com", "ImageNow License Request");
        email.setFrom("ImageNowLicenseRequest@lexmark.com", "ImageNow License Request");
        // Create the attachment
        EmailAttachment attachment = new EmailAttachment();
        attachment.setPath(fileNameToCopy.getAbsolutePath());
        attachment.setDisposition(EmailAttachment.ATTACHMENT);
        attachment.setDescription(originalFileName);
        attachment.setName(originalFileName);
        email.attach(attachment);
        //Send mail to scrum masters
        for (EmployeeBO item : employeeBL.getAllEmployeesKeyedByGroupId().get(Integer.valueOf("14"))) {
            email.addTo(item.getEmail(), item.getEmployeeName());
        }
        //email.addTo("saibal.ghosh@perceptivesoftware.com","Saibal Ghosh");
        email.addCc(imagenowlicenses.getEmployeeByRequestedByEmployeeId().getEmail());
        email.send();

    } catch (Exception ex) {
        throw new ExceptionWrapper(ex);
    }
}