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.mbrlabs.mundus.core.ImportManager.java

public ImportedModel importToTempFolder(FileHandle modelFile, FileHandle textureFile) {
    if (modelFile == null || !modelFile.exists()) {
        return null;
    }/*from   w w  w  . j  av  a  2  s  .  c  om*/
    if (textureFile == null || !textureFile.exists()) {
        return null;
    }

    ImportedModel imported = new ImportedModel();
    FileHandle tempModelCache = registry.createTempFolder();

    // copy texture file to temp folder
    textureFile.copyTo(tempModelCache);
    imported.textureFile = Gdx.files.absolute(FilenameUtils.concat(tempModelCache.path(), textureFile.name()));

    // check if copied texture file exists
    if (!imported.textureFile.exists()) {
        return null;
    }

    // copy model file
    modelFile.copyTo(tempModelCache);
    FileHandle rawModelFile = Gdx.files.absolute(FilenameUtils.concat(tempModelCache.path(), modelFile.name()));
    if (!rawModelFile.exists()) {
        return null;
    }

    // convert copied importer
    boolean convert = FileFormatUtils.isFBX(rawModelFile) || FileFormatUtils.isCollada(rawModelFile)
            || FileFormatUtils.isWavefont(rawModelFile);

    if (convert) {
        fbxConv.clear();
        imported.convResult = fbxConv.input(rawModelFile.path()).output(tempModelCache.file().getAbsolutePath())
                .flipTexture(true).execute();

        if (imported.convResult.isSuccess()) {
            imported.g3dbFile = Gdx.files.absolute(imported.convResult.getOutputFile());
        }
    } else if (FileFormatUtils.isG3DB(rawModelFile)) {
        imported.g3dbFile = rawModelFile;
    }

    // check if converted file exists
    if (imported.g3dbFile == null || !imported.g3dbFile.exists()) {
        return null;
    }

    return imported;
}

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

@Test
public void testPeakFinding() throws IOException {
    final String basename = FilenameUtils.concat(BASE_TEST_DIR, "counts-101.bin");
    writeSomeCounts(basename);/*from  www .j  av  a  2s. c  o m*/
    CountsReader countReader = new CountsReader(new FileInputStream(basename));
    PeakAggregator peakIterator = new PeakAggregator(countReader);
    int count = 0;
    while (peakIterator.hasNext()) {
        final Peak peak = peakIterator.next();
        System.out.println(peak);
        count++;
    }
    assertEquals(2, count);

    // rewind and start again:
    countReader = new CountsReader(new FileInputStream(basename));
    peakIterator = new PeakAggregator(countReader);

    assertTrue(peakIterator.hasNext());
    Peak peak = peakIterator.next();
    assertEquals(5, peak.start);

    assertEquals(lengthB + lengthC, peak.length);
    assertEquals(13, peak.count);

    peak = peakIterator.next();
    assertEquals(lengthA + lengthB + lengthC + lengthA, peak.start);
    assertEquals(lengthD, peak.length);
    assertEquals(10, peak.count);
}

From source file:com.xiaomi.linden.core.TestHotSwapLindenCore.java

public void init() throws Exception {
    LindenSchema schema = new LindenSchema().setId("id");
    schema.addToFields(/*from   ww w.  ja v a 2 s.  c  o m*/
            new LindenFieldSchema().setName("title").setIndexed(true).setStored(true).setTokenized(true));

    lindenConfig = new LindenConfig();
    lindenConfig.setClusterUrl("127.0.0.1:2181/test");
    lindenConfig.setSchema(schema);
    String path = FilenameUtils.concat(TestMultiLindenCore.class.getResource("./").getPath(), "index/");
    FileUtils.deleteQuietly(new File(path));
    lindenConfig.setIndexDirectory(path);
    lindenConfig.setLindenCoreMode(LindenConfig.LindenCoreMode.HOTSWAP);
}

From source file:es.urjc.mctwp.bbeans.research.upload.FileUploadBean.java

public String accUploadFiles() throws IOException {
    List<File> files = new ArrayList<File>();
    String base = getSession().getAbsoluteThumbDir();
    String action = "uploadSuccess";

    //Get uploaded files wrote to disk
    if (img1 != null) {
        File f = new File(FilenameUtils.concat(base, img1.getName()));
        FileUtils.writeByteArrayToFile(f, img1.getBytes());
        files.add(f);//from ww  w  . ja  v  a  2s. c om
    }
    if (img2 != null) {
        File f = new File(FilenameUtils.concat(base, img2.getName()));
        FileUtils.writeByteArrayToFile(f, img2.getBytes());
        files.add(f);
    }

    Command cmd = getCommand(StoreTemporalImages.class);
    ((StoreTemporalImages) cmd).setFiles(files);
    runCommand(cmd);

    return action;
}

From source file:com.mbrlabs.mundus.utils.TerrainIO.java

public static Terrain importTerrain(ProjectContext projectContext, Terrain terrain) {
    FloatArray floatArray = new FloatArray();

    String terraPath = FilenameUtils.concat(projectContext.path, terrain.terraPath);
    try (DataInputStream is = new DataInputStream(
            new BufferedInputStream(new GZIPInputStream(new FileInputStream(terraPath))))) {
        while (is.available() > 0) {
            floatArray.add(is.readFloat());
        }//from  w w w .  j  ava2s.com
    } catch (EOFException e) {
        //e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    //Log.debug("Terrain import. floats: " + floatArray.size);

    terrain.heightData = floatArray.toArray();
    terrain.init();
    terrain.update();

    // set default terrain base texture if none is present
    TerrainTexture terrainTexture = terrain.getTerrainTexture();
    if (terrainTexture.getTexture(SplatTexture.Channel.BASE) == null) {
        MTexture base = new MTexture();
        base.setId(-1);
        base.texture = TextureUtils.loadMipmapTexture(Gdx.files.internal("textures/terrain/chess.png"), true);
        terrainTexture.setSplatTexture(new SplatTexture(SplatTexture.Channel.BASE, base));
    }

    // load splat map if available
    SplatMap splatmap = terrainTexture.getSplatmap();
    if (splatmap != null) {
        String splatPath = FilenameUtils.concat(projectContext.path, splatmap.getPath());
        splatmap.loadPNG(Gdx.files.absolute(splatPath));
    }

    return terrain;
}

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

@Test
public void testCache() throws IOException {

    final String basename = FilenameUtils.concat(BASE_TEST_DIR, "101.bin");
    final CountsArchiveWriter writer = new CountsArchiveWriter(basename);

    CountsWriterI cw = writer.newCountWriter(0, "count-0");
    cw.appendCount(0, 10000);/*from w ww .  jav a2  s . c  o  m*/
    cw.appendCount(10, 10000);
    cw.appendCount(20, 10000);
    cw.close();
    writer.returnWriter(cw);

    // read counts 1
    cw = writer.newCountWriter(1, "count-1");
    cw.appendCount(0, 20000);
    cw.appendCount(10, 20000);
    cw.appendCount(20, 20000);
    cw.appendCount(30, 20000);
    cw.close();
    writer.returnWriter(cw);
    writer.close();

    CachingCountsArchiveReader reader = new CachingCountsArchiveReader(basename);
    CountsReaderI countReader = reader.getCountReader("count-0");
    countReader.reposition(10000);
    // read the cached reader again:
    CountsReaderI countReader2 = reader.getCountReader("count-0");
    countReader2.reposition(10000);
}

From source file:eu.dime.userresolver.service.user.OrmLiteUserProvider.java

public OrmLiteUserProvider() {
    properties = new Properties();
    try {//from  w w w . j  a v a  2 s .co  m
        properties.load(OrmLiteUserProvider.class.getResourceAsStream(PROPERTIES_URI));

        appFolder = new File(
                FilenameUtils.concat(FileUtils.getUserDirectoryPath(), properties.getProperty("app.folder")));

        FileUtils.forceMkdir(appFolder);
    } catch (IOException e) {
        LOG.error("Unable to create app folder", e);
        throw new RuntimeException("Unable to load properties", e);
    }

    try {
        connectionSource = new JdbcConnectionSource(
                "jdbc:sqlite:" + FilenameUtils.concat(appFolder.getAbsolutePath(), "resolver.db"));

        userDao = DaoManager.createDao(connectionSource, User.class);

        // schema upgrade "hack"
        try {
            userDao.executeRaw("ALTER TABLE `users` ADD COLUMN key STRING;");
        } catch (SQLException e) {
            LOG.info("Schema update failed. Already updated?");
        }

        TableUtils.createTableIfNotExists(connectionSource, User.class);
    } catch (SQLException e) {
        LOG.error("Unable to create database", e);
        throw new RuntimeException("Unable to create database", e);
    }

}

From source file:au.org.ala.delta.confor.ToIntTest.java

@Test
public void testSampleToInt() throws Exception {

    File tointDirectory = urlToFile("/dataset/");
    File dest = new File(System.getProperty("java.io.tmpdir"));
    FileUtils.copyDirectory(tointDirectory, dest);

    String tointFilePath = FilenameUtils.concat(dest.getAbsolutePath(), "sample/toint");

    CONFOR.main(new String[] { tointFilePath });

    File ichars = new File(FilenameUtils.concat(dest.getAbsolutePath(), "sample/ichars"));
    File iitems = new File(FilenameUtils.concat(dest.getAbsolutePath(), "sample/iitems"));

    IntkeyDataset dataSet = IntkeyDatasetFileReader.readDataSet(ichars, iitems);

    File expectedIChars = new File(
            FilenameUtils.concat(dest.getAbsolutePath(), "sample/expected_results/ichars"));
    File expectedIItems = new File(
            FilenameUtils.concat(dest.getAbsolutePath(), "sample/expected_results/iitems"));

    IntkeyDataset expectedDataSet = IntkeyDatasetFileReader.readDataSet(expectedIChars, expectedIItems);

    compare(dataSet, expectedDataSet);/*from   w w w.  j  a  v a2 s  .c o  m*/

}

From source file:com.mbrlabs.mundus.assets.ModelImporter.java

public ImportedModel importToTempFolder(FileHandle modelFile) {
    if (modelFile == null || !modelFile.exists()) {
        return null;
    }/*  ww w.ja  va2s .  c  o  m*/

    ImportedModel imported = new ImportedModel();
    FileHandle tempModelCache = registry.createTempFolder();

    // copy model file
    modelFile.copyTo(tempModelCache);
    FileHandle rawModelFile = Gdx.files.absolute(FilenameUtils.concat(tempModelCache.path(), modelFile.name()));
    if (!rawModelFile.exists()) {
        return null;
    }

    // convert copied importer
    boolean convert = FileFormatUtils.isFBX(rawModelFile) || FileFormatUtils.isCollada(rawModelFile)
            || FileFormatUtils.isWavefont(rawModelFile);

    if (convert) {
        fbxConv.clear();
        imported.convResult = fbxConv.input(rawModelFile.path()).output(tempModelCache.file().getAbsolutePath())
                .flipTexture(true).execute();

        if (imported.convResult.isSuccess()) {
            imported.g3dbFile = Gdx.files.absolute(imported.convResult.getOutputFile());
        }
    } else if (FileFormatUtils.isG3DB(rawModelFile)) {
        imported.g3dbFile = rawModelFile;
    }

    // check if converted file exists
    if (imported.g3dbFile == null || !imported.g3dbFile.exists()) {
        return null;
    }

    return imported;
}

From source file:com.perceptive.epm.perkolcentral.action.ExcelReportAction.java

public String execute() throws ExceptionWrapper {
    try {//w ww  . j a v  a  2  s. c o m

        if (reportKey.equalsIgnoreCase(Constants.REPORT_ALL_USER)) {
            reportName = Constants.REPORT_ALL_USER + ".xlsx";
            File tempFile = new File(
                    FilenameUtils.concat(FileUtils.getTempDirectoryPath(), UUID.randomUUID() + ".xlsx"));
            FileUtils.copyInputStreamToFile(ServletActionContext.getServletContext().getResourceAsStream(
                    String.format("%s/%s", pathToExcelReportTemplateFolder, "AllEmployeeReportTemplate.xlsx")),
                    tempFile);
            reportInputStream = excelReportBL.generateAllEmployeeReport(tempFile);
            FileUtils.deleteQuietly(tempFile);
        }
        if (reportKey.equalsIgnoreCase(Constants.REPORT_ALL_USER_SCRUM_TEAM_WISE)) {
            reportName = Constants.REPORT_ALL_USER_SCRUM_TEAM_WISE + ".xlsx";
            File tempFile = new File(
                    FilenameUtils.concat(FileUtils.getTempDirectoryPath(), UUID.randomUUID() + ".xlsx"));
            FileUtils.copyInputStreamToFile(
                    ServletActionContext.getServletContext().getResourceAsStream(String.format("%s/%s",
                            pathToExcelReportTemplateFolder, "AllEmployeeScrumTeamWiseReportTemplate.xlsx")),
                    tempFile);
            reportInputStream = excelReportBL.generateAllEmployeeTeamWiseReport(tempFile, true);
            FileUtils.deleteQuietly(tempFile);
        }
        if (reportKey.equalsIgnoreCase(Constants.REPORT_ALL_USER_NONSCRUM_TEAM_WISE)) {
            reportName = Constants.REPORT_ALL_USER_NONSCRUM_TEAM_WISE + ".xlsx";
            File tempFile = new File(
                    FilenameUtils.concat(FileUtils.getTempDirectoryPath(), UUID.randomUUID() + ".xlsx"));
            FileUtils.copyInputStreamToFile(ServletActionContext.getServletContext().getResourceAsStream(
                    String.format("%s/%s", pathToExcelReportTemplateFolder, "AllEmployeeReportTemplate.xlsx")),
                    tempFile);
            reportInputStream = excelReportBL.generateAllEmployeeTeamWiseReport(tempFile, false);
            FileUtils.deleteQuietly(tempFile);
        }
        if (reportKey.equalsIgnoreCase(Constants.REPORT_LICENSE)) {
            reportName = Constants.REPORT_LICENSE + ".xlsx";
            File tempFile = new File(
                    FilenameUtils.concat(FileUtils.getTempDirectoryPath(), UUID.randomUUID() + ".xlsx"));
            FileUtils.copyInputStreamToFile(ServletActionContext.getServletContext().getResourceAsStream(
                    String.format("%s/%s", pathToExcelReportTemplateFolder, "LicenseReportTemplate.xlsx")),
                    tempFile);
            reportInputStream = excelReportBL.generateLicenseReport(tempFile);
            FileUtils.deleteQuietly(tempFile);
        }
    } catch (Exception ex) {
        throw new ExceptionWrapper(ex);
    }
    return SUCCESS;
}