Example usage for java.io File getAbsoluteFile

List of usage examples for java.io File getAbsoluteFile

Introduction

In this page you can find the example usage for java.io File getAbsoluteFile.

Prototype

public File getAbsoluteFile() 

Source Link

Document

Returns the absolute form of this abstract pathname.

Usage

From source file:com.github.sakserv.minicluster.yarn.util.ExecShellCliParser.java

public void writeOutputToFile(String output, File outputFile) throws IOException {
    File parentDir = outputFile.getAbsoluteFile().getParentFile();
    parentDir.mkdirs();//from   w  ww.  j  a  va 2 s  .  co  m
    org.apache.commons.io.FileUtils.writeStringToFile(outputFile, output);
}

From source file:de.doering.dwca.dbpedia.ChecklistBuilder.java

public File build() throws IOException {
    // new writer
    File dwcaDir = FileUtils.createTempDir("dbpedia-", "");
    File dwcaZip = new File(dwcaDir.getAbsoluteFile() + ".zip");
    log.info("Writing archive files to temporary folder " + dwcaDir);
    writer = new DwcaWriter(DwcTerm.Taxon, dwcaDir);

    // metadata// w  w w  .  j av  a2s.co m
    Eml eml = new Eml();
    eml.setTitle(TITLE);
    Citation cite = new Citation();
    cite.setCitation(CITATION);
    eml.setCitation(cite);
    eml.setDescription(DESCRIPTION);
    eml.setHomepageUrl(HOMEPAGE);
    eml.setLogoUrl(LOGO);

    // parse file and some metadata
    parseData();

    // finish archive and zip it
    log.info("Bundling archive at {}", dwcaZip);
    writer.setEml(eml);
    writer.finalize();

    // compress
    CompressionUtil.zipDir(dwcaDir, dwcaZip);
    // remove temp folder
    //org.apache.commons.io.FileUtils.deleteDirectory(dwcaDir);

    log.info("Dwc archive completed at {} !", dwcaZip);

    return dwcaZip;
}

From source file:it.geosolutions.tools.io.CollectorTests.java

@Test
public final void testCollect() throws Exception {
    Collector c = new Collector(FileFilterUtils.or(new WildcardFileFilter("*_PCK.xml", IOCase.INSENSITIVE),
            new WildcardFileFilter("*_PRO", IOCase.INSENSITIVE)));

    File location = TestData.file(this, "collector");

    LOGGER.info("Location: " + location.getAbsoluteFile());

    assertNotNull(location);/*from   www  .j  a va 2s .c  o m*/

    assertTrue(location.exists());

    List<File> list = c.collect(location);

    assertNotNull(list);

    LOGGER.info("Number of files..." + list.size());

    for (File f : list) {
        LOGGER.info("FILE: " + f.getAbsolutePath());
    }

    assertEquals("Wrong number of files...", FILES_IN_TEST, list.size());

}

From source file:edu.clemson.cs.nestbed.server.nesc.weaver.WiringDiagramWeaver.java

public WiringDiagramWeaver(File nescFile) throws Exception {
    nescFile = nescFile.getAbsoluteFile();

    log.info("Top-Level configuration " + nescFile.getAbsolutePath());

    toolkit = new NescToolkit(nescFile, nescFile.getAbsoluteFile().getParentFile());
    toolkit.addIncludePath("/opt/tinyos-2.x/tos/lib/net");
    toolkit.addIncludePath("/opt/tinyos-2.x/tos/lib/net/ctp");
    toolkit.addIncludePath("/opt/tinyos-2.x/tos/lib/net/le");

    toolkit.appendGccArgument("-I");
    toolkit.appendGccArgument("/opt/tinyos-2.x/tos/lib/net");
    toolkit.appendGccArgument("-I");
    toolkit.appendGccArgument("/opt/tinyos-2.x/tos/lib/net/ctp");
    toolkit.appendGccArgument("-I");
    toolkit.appendGccArgument("/opt/tinyos-2.x/tos/lib/net/le");

    Map<String, SourceFile> sourceFileMap = toolkit.load();
    sourceFile = sourceFileMap.get(nescFile.getName());
    FileUtils.deleteRecursive(new File(nescFile.getParent(), "analysis"));
}

From source file:de.doering.dwca.invasivespecies.ChecklistBuilder.java

public File build() throws IOException {
    // new writer
    File dwcaDir = FileUtils.createTempDir("invasives-", "-dwca");
    File dwcaZip = new File(dwcaDir.getAbsoluteFile() + ".zip");
    log.info("Writing archive files to temporary folder " + dwcaDir);
    writer = new DwcaWriter(DwcTerm.Taxon, dwcaDir);

    // parse file
    parsePage();/*from w ww.jav  a 2s  . c om*/

    // finish archive and zip it
    log.info("Bundling archive at {}", dwcaZip);
    writer.setEml(buildEml());
    writer.finalize();

    // compress
    CompressionUtil.zipDir(dwcaDir, dwcaZip);
    // remove temp folder
    org.apache.commons.io.FileUtils.deleteDirectory(dwcaDir);

    log.info("Dwc archive completed at {} !", dwcaZip);

    return dwcaZip;
}

From source file:com.github.dozermapper.core.builder.xml.DefaultJAXBModelParserTest.java

@Test
public void testCurrentMappingXML() throws IOException, SAXException {
    JAXBModelParser<MappingsDefinition> factory = new DefaultJAXBModelParser<>(new BeanContainer());

    File folder = new File(new File(".").getCanonicalPath() + "/src/test/resources/mappings");
    File[] listOfFiles = folder.listFiles();

    LOG.info("Found {} to validate.", listOfFiles.length);

    for (File file : listOfFiles) {
        if (file.isFile()) {
            LOG.info("Validating {}", file.getAbsoluteFile());

            try (FileInputStream fileInputStream = new FileInputStream(file)) {
                String xmlContent = IOUtils.toString(fileInputStream, Charset.forName("UTF-8"));

                MappingsDefinition mapping = factory.readXML(xmlContent, MappingsDefinition.class);

                assertNotNull(mapping);/* w w  w .j  a v a2  s. c o  m*/

                factory.validateXML(xmlContent);
            }
        }
    }
}

From source file:de.doering.dwca.iocwbn.ChecklistBuilder.java

public File build() throws IOException, SAXException, ParserConfigurationException {
    // new writer
    File dwcaDir = FileUtils.createTempDir("iocwbn-", "");
    File dwcaZip = new File(dwcaDir.getAbsoluteFile() + ".zip");
    log.info("Writing archive files to temporary folder " + dwcaDir);
    writer = new DwcaWriter(DwcTerm.Taxon, dwcaDir);

    // metadata//  w  w  w. j av  a  2  s . c o  m
    Eml eml = new Eml();
    eml.setDescription(DESCRIPTION);
    eml.setLanguage(LANGUAGE);
    eml.setHomepageUrl(HOMEPAGE);
    eml.setLogoUrl(LOGO);
    org.gbif.metadata.eml.Agent contact = new org.gbif.metadata.eml.Agent();
    contact.setFirstName(CONTACT_FIRSTNAME);
    contact.setLastName(CONTACT_LASTNAME);
    contact.setHomepage(CONTACT_LINK);
    eml.setContact(contact);
    // parse file and some metadata
    parsePage(eml);

    // finish archive and zip it
    log.info("Bundling archive at {}", dwcaZip);
    writer.setEml(eml);
    writer.finalize();

    // compress
    CompressionUtil.zipDir(dwcaDir, dwcaZip);
    // remove temp folder
    //org.apache.commons.io.FileUtils.deleteDirectory(dwcaDir);

    log.info("Dwc archive completed at {} !", dwcaZip);

    return dwcaZip;
}

From source file:android.databinding.tool.writer.JavaFileWriter.java

public void writeToFile(File exactPath, String contents) {
    File parent = exactPath.getParentFile();
    parent.mkdirs();// ww w. jav  a 2s . c  o  m
    try {
        L.d("writing file %s", exactPath.getAbsoluteFile());
        FileUtils.writeStringToFile(exactPath, contents);
    } catch (IOException e) {
        L.e(e, "Could not write to %s", exactPath);
    }
}

From source file:de.doering.dwca.flickr.OccurrenceExport.java

public File build() throws IOException {
    // new writer
    File dwcaDir = FileUtils.createTempDir("flickr-", "-dwca");
    File dwcaZip = new File(dwcaDir.getAbsoluteFile() + ".zip");
    log.info("Writing archive files to temporary folder " + dwcaDir);
    writer = new DwcaWriter(DwcTerm.Occurrence, dwcaDir);
    imgWriter = new ImageWriter(writer);

    // parse file
    export();//from ww w . j  ava  2  s . c o  m

    // finish archive and zip it
    log.info("Bundling archive at {}", dwcaZip);
    writer.setEml(buildEml());
    writer.finalize();

    // compress
    CompressionUtil.zipDir(dwcaDir, dwcaZip);
    // remove temp folder
    org.apache.commons.io.FileUtils.deleteDirectory(dwcaDir);

    log.info("Dwc archive completed at {} !", dwcaZip);

    return dwcaZip;
}

From source file:au.org.ala.bhl.command.PaginateDocCacheCommand.java

private void paginateFile(File file, IndexerOptions options) {
    log("Paginating file: %s", file.getAbsoluteFile());
    DocumentPaginator paginator = new DocumentPaginator();

    String dirname = String.format("%s\\%s", options.getDocCachePath(),
            file.getName().substring(0, file.getName().length() - 4));

    final File documentDir = new File(dirname);

    if (!documentDir.exists()) {
        log("Creating directory: %s", documentDir.getAbsoluteFile());
        documentDir.mkdir();/*from w  w w.j av  a2 s . c o  m*/

    }

    if (documentDir.exists() && documentDir.isDirectory()) {

        paginator.paginate(file.getAbsolutePath(), new PageHandler() {

            public void handlePage(String pageId, String pageText) {
                String pagePath = String.format("%s\\%s.txt", documentDir.getAbsolutePath(), pageId);
                try {
                    File f = new File(pagePath);
                    if (!f.exists()) {
                        FileUtils.writeStringToFile(f, pageText);
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

        });
    } else {

    }
}