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:com.abiquo.am.services.DiskFileServiceImpl.java

@Override
public void copy(String source, final String destination) {
    source = customEncode(source); // source is automatic decoded ( :9000 -> %3A9000)

    LOGGER.info("Copying disk file from [{}] to [{}]", source, destination);

    final File sourceFile = getFile(source);
    final File destinationFile = new File(FilenameUtils.concat(repositoryPath, destination));

    if (destinationFile.exists()) {
        throw new AMException(AMError.DISK_FILE_ALREADY_EXIST, destination);
    }//from  ww w .  ja v a  2s. c  o  m

    if (!sourceFile.exists()) {
        throw new AMException(AMError.DISK_FILE_NOT_FOUND, source);
    }

    try {
        FileUtils.copyFile(sourceFile, destinationFile);
    } catch (IOException e) {
        throw new AMException(AMError.DISK_FILE_COPY_ERROR, e);
    }

    LOGGER.info("Copy process finished");
}

From source file:com.mbrlabs.mundus.core.registry.Registry.java

public ProjectRef createProjectRef(String name, String folder) {
    ProjectRef projectRef = new ProjectRef();
    projectRef.setName(name);/* w  w w.j  a  v a  2  s .  c  om*/
    projectRef.setPath(FilenameUtils.concat(folder, name));
    projects.add(projectRef);

    return projectRef;
}

From source file:com.zappy.purefit6.service.DayFacadeREST.java

/**
 * Creates new week program./* www  . ja  va 2 s. co  m*/
 * @param uploadedInputStream   Image file      FORM
 * @param fileDetail            Image details   FORM
 * @param name                  Name            FORM
 */
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
public void create(@FormDataParam("image") InputStream uploadedInputStream,
        @FormDataParam("image") FormDataContentDisposition fileDetail, @FormDataParam("index") int index,
        @FormDataParam("calories") int calories, @FormDataParam("workoutTime") int workoutTime,
        @FormDataParam("idWeek") int idWeek) {

    try {
        //Copy file
        File destination = new File(
                FilenameUtils.concat("/home/gianksp/Desktop/test/day", fileDetail.getFileName()));
        FileUtils.copyInputStreamToFile(uploadedInputStream, destination);
        //Create element
        Day day = new Day();
        day.setIndexPos(index);
        day.setCalories(calories);
        day.setWorkoutTime(workoutTime);
        day.setImagePath(destination.getAbsolutePath());
        //Store element
        super.create(day);
    } catch (IOException ex) {
        log.log(Level.SEVERE, "Unable to import program day image " + " .image:" + fileDetail.getName()
                + " .index:" + index + " .week:" + idWeek, ex);
    } catch (Exception ex) {
        log.log(Level.SEVERE, "Unable to import program day image " + " .index:" + index + " .week:" + idWeek,
                ex);
    }
}

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

@Test
// check that large-sort can sort a small alignment (only one split):
public void sortSmall() throws IOException {
    SortMode mode = new SortMode();
    mode.setInput("test-data/alignment-hybrid-codec/EJOYQAZ-small.header");
    mode.setOutput(FilenameUtils.concat(BASE_TEST_DIR, "EJOYQAZ-small-sorted"));
    mode.setNumThreads(1);//  ww w. jav  a  2 s . c  o  m
    mode.setSplitSize(1 * 1024 * 1024);
    mode.execute();
    // quick way to check the entries and header files were created. Since it is a checksum, if the test fails, it is possible
    // content is correct, but written sligthly differently.
    assertEquals(1947630632, FileUtils
            .checksumCRC32(new File(FilenameUtils.concat(BASE_TEST_DIR, "EJOYQAZ-small-sorted.entries"))));
    assertEquals(2375098082L, FileUtils
            .checksumCRC32(new File(FilenameUtils.concat(BASE_TEST_DIR, "EJOYQAZ-small-sorted.header"))));
}

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

@Test
public void testExport() throws Exception {
    ExportController controller = new ExportController(_helper);
    File tmpDir = new File(System.getProperty("java.io.tmpdir"));
    List<DirectiveFileInfo> files = new ArrayList<DirectiveFileInfo>();
    DirectiveFileInfo specs = new DirectiveFileInfo("specs", DirectiveType.CONFOR);
    files.add(specs);/*from  www  . j  ava 2  s .  co  m*/
    DirectiveFileInfo chars = new DirectiveFileInfo("chars", DirectiveType.CONFOR);
    files.add(chars);
    DirectiveFileInfo items = new DirectiveFileInfo("items", DirectiveType.CONFOR);
    files.add(items);

    controller.new DoExportTask(tmpDir, files, true).doInBackground();

    File exportedSpecs = new File(FilenameUtils.concat(tmpDir.getAbsolutePath(), "specs"));
    String specsText = FileUtils.readFileToString(exportedSpecs);
    assertTrue(specsText.contains("*NUMBER OF CHARACTERS 3"));
    assertTrue(specsText.contains("*MAXIMUM NUMBER OF STATES 4"));
    assertTrue(specsText.contains("*MAXIMUM NUMBER OF ITEMS 4"));
    assertTrue(specsText.contains("*CHARACTER TYPES"));
    assertTrue(specsText.contains("*NUMBERS OF STATES 1,4 3,3"));

    File exportedChars = new File(FilenameUtils.concat(tmpDir.getAbsolutePath(), "chars"));
    String charsText = FileUtils.readFileToString(exportedChars);
    assertTrue(charsText.contains("CHARACTER LIST"));

    File exportedItems = new File(FilenameUtils.concat(tmpDir.getAbsolutePath(), "items"));
    String itemsText = FileUtils.readFileToString(exportedItems);
    assertTrue(itemsText.contains("ITEM DESCRIPTIONS"));
}

From source file:edu.cornell.med.icb.goby.counts.TestReadWriteCounts.java

@Test
public void testReadWrite() throws IOException {
    final String basename = FilenameUtils.concat(BASE_TEST_DIR, "counts-101.bin");
    final CountsWriterI writerI = new CountsWriter(new FileOutputStream(basename), 45);

    writerI.appendCount(10, 1);/*from ww w  .  ja va  2 s  .  co m*/
    writerI.appendCount(15, 1);

    writerI.close();

    final CountsReader reader = new CountsReader(new FileInputStream(basename));

    assertTrue(reader.hasNextPosition());
    assertEquals(10, reader.nextCountAtPosition());
    assertEquals(15, reader.nextCountAtPosition());
    assertFalse(reader.hasNextPosition());
}

From source file:com.stanley.captioner.MainFrame.java

public void caption() {
    Converter converter = new Converter();

    Configuration config = new Configuration();
    config.setAcousticModelPath("resource:/edu/cmu/sphinx/models/en-us/en-us");
    config.setDictionaryPath("resource:/edu/cmu/sphinx/models/en-us/cmudict-en-us.dict");
    config.setLanguageModelPath("resource:/edu/cmu/sphinx/models/en-us/en-us.lm.bin");

    for (int i = 0; i < videoTable.getRowCount(); i++) {
        String videoInPath = (String) videoTable.getValueAt(i, 0);
        File videoIn = new File(videoInPath);
        String videoInDirPath = videoIn.getParent();
        String audioOutPath = FilenameUtils.concat(videoInDirPath,
                FilenameUtils.getBaseName(videoInPath) + ".wav");
        File audioOut = new File(audioOutPath);
        tempFiles.add(audioOut);//from  ww  w  . ja va  2 s . com
        String outputPath = outputDirectoryField.getText();
        String textOutPath = FilenameUtils.concat(outputPath, FilenameUtils.getBaseName(videoInPath) + ".txt");
        File textOut = new File(textOutPath);
        String videoOutPath = FilenameUtils.concat(outputPath, FilenameUtils.getBaseName(videoInPath) + ".mp4");
        File videoOut = new File(videoOutPath);
        System.out.println(videoInPath);
        System.out.println(audioOutPath);
        System.out.println(outputPath);
        System.out.println(textOutPath);
        System.out.println(videoOutPath);
        converter.videoToAudio(videoIn, audioOut);
        Transcriber transcriber = new Transcriber(audioOut, config, textOut, videoIn,
                quickTestCheckBox.isSelected());
        transcriber.start();

        //Converter.imagesFromVideo(videoIn);
        //Converter.videoFromImages(videoIn, videoOut);
    }
}

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

protected void doFileOperator(String src, String dst, String fileName) throws Exception {
    if (Thread.currentThread().isInterrupted())
        return;//w  ww  .ja v a  2s .com
    String baseName = FilenameUtils.getName(src);
    updateStatusInfo("copying file " + baseName);
    // if is same file, make a copy
    if (fileModelManager.isSameFile(src, dst)) {
        dst = FilenameUtils.concat(dst,
                FilenameUtils.getBaseName(src) + "(1)." + FilenameUtils.getExtension(src));
        new File(dst).createNewFile();
    }
    fileModelManager.cp(src, dst);
}

From source file:com.cubeia.games.poker.war.service.WarServerService.java

/** 
 * Takes a relative to the cwd (current work dir, poker-uar) path and 
 * creates the absolute path to the war file.
 * <p>//from  w w w  .j a v  a 2s.  c o m
 * TODO: this needs to be changed to use either java or firebase mechanics
 * to determine cwd and the war location in a more elegant (ideally 
 * generic) way.
 *
 * @param war the relative path to the war
 * @return the absolute path to the war
 */
public String getWarPath(String war) {
    File file;
    String sarRoot;
    try {
        file = new File(getClass().getProtectionDomain().getCodeSource().getLocation().toURI().getPath());
        sarRoot = file.getParent();
    } catch (URISyntaxException ex) {
        log.debug(null, ex);
        sarRoot = "";
    }
    String libDir = FilenameUtils.concat(sarRoot, "META-INF/lib");
    String warPath = FilenameUtils.concat(libDir, war);
    log.debug("warPath : " + warPath);
    return warPath;
}

From source file:au.org.ala.delta.delfor.DelforTest.java

private void checkResults(String path, String resultFileName) throws Exception {

    String expectedResultFileName = resultFileName;
    if (resultFileName.equals("intkey.ini.new")) {
        expectedResultFileName = "intkey.new";
    }//from w w w  .  j a  v a 2  s .  c  om
    java.io.File expectedFile = new File(
            FilenameUtils.concat(path, "expected_results/" + expectedResultFileName));
    String expected = FileUtils.readFileToString(expectedFile, "cp1252");

    System.out.println(expected);

    File actualFile = new File(FilenameUtils.concat(path, resultFileName));
    String actual = FileUtils.readFileToString(actualFile, "cp1252");

    System.out.print(actual);
    expected = replaceNewLines(expected);

    // CONFOR leaves a lot of trailing spaces around
    expected = expected.replaceAll(" ([\\r\\n]+)", "$1");
    actual = actual.replaceAll(" ([\\r\\n]+)", "$1");

    assertEquals(resultFileName, expected, actual);
}