Example usage for org.springframework.core.io Resource getFile

List of usage examples for org.springframework.core.io Resource getFile

Introduction

In this page you can find the example usage for org.springframework.core.io Resource getFile.

Prototype

File getFile() throws IOException;

Source Link

Document

Return a File handle for this resource.

Usage

From source file:org.fao.fenix.maps.configurations.MapsConf.java

public MapsConf(Resource styles, Resource images) {
    try {//  w  w  w . j a  v  a  2  s.  c om
        this.setStylesPath(styles.getFile().getPath());
        this.setImagesPath(images.getFile().getPath());
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:org.craftercms.commerce.client.itest.data.MongoTestDataService.java

public void createTestData() throws Exception {
    Resource resource = new ClassPathResource(TEST_DATA_FILE);
    File file = resource.getFile();

    //Order order = mapper.readValue(file, Order.class);
    //mongoTemplate.save(order, Order.class.getName());

    //      Set<Order> orders = mapper.readValue(file, new TypeReference<Set<Order>>() {});
    //      mongoTemplate.insert(orders, Order.class.getName());

    LOGGER.info("Finished creating Mongo test data.");
}

From source file:org.eclipse.gemini.blueprint.test.parsing.CaseWithVisibleMethodsBaseTest.java

public String getRootPath() {
    ResourceLoader fileLoader = new DefaultResourceLoader();
    try {//from w w w. ja va 2  s. c  om
        String classFile = CaseWithVisibleMethodsBaseTest.class.getName().replace('.', '/').concat(".class");
        Resource res = fileLoader.getResource(classFile);
        String fileLocation = "file:/" + res.getFile().getAbsolutePath();
        String classFileToPlatform = CaseWithVisibleMethodsBaseTest.class.getName()
                .replace('.', File.separatorChar).concat(".class");
        return fileLocation.substring(0, fileLocation.indexOf(classFileToPlatform));
    } catch (Exception ex) {
    }

    return null;
}

From source file:nl.tue.gale.ae.LogManager.java

public void setLogDir(org.springframework.core.io.Resource logDirP) {
    try {//ww  w  .j a  v a2  s. co m
        logDir = logDirP.getFile();
        if (!logDir.exists())
            logDir.mkdir();
    } catch (Exception e) {
        throw new IllegalArgumentException("unable to open log directory: " + e.getMessage());
    }
}

From source file:de.appsolve.padelcampus.controller.CacheManifestController.java

private void appendFolder(StringBuilder sb, StringBuilder hash, String path, String pathMapping)
        throws IOException {
    Resource resourceFolder = applicationContext.getResource(path);
    File folder = resourceFolder.getFile();
    appendContentsOfFolder(sb, hash, folder, path, pathMapping);
}

From source file:com.javacreed.api.secureproperties.spring.PropertiesFilePlaceholderConfigurer.java

private Resource[] encodeProperties(final Resource[] modifiableLocations) throws Exception {
    for (final Resource resource : modifiableLocations) {
        final File file = resource.getFile().getAbsoluteFile();
        if (file.isFile()) {
            PropertiesFilePlaceholderConfigurer.LOGGER.debug("Processing properties file: {}", file);
            propertiesFile.loadProperties(file);
        }//from   w  w w  .  ja v a 2 s.  co  m
    }

    return modifiableLocations;
}

From source file:org.brekka.stillingar.spring.resource.dir.EnvironmentVariableDirectoryTest.java

@Test
public void found() throws Exception {
    Map<String, String> map = new HashMap<String, String>();
    map.put("TEST", System.getProperty("java.io.tmpdir"));
    EnvironmentVariableDirectory envVarDir = new EnvironmentVariableDirectory("TEST", map);
    Resource dirResource = envVarDir.getDirResource();
    assertEquals(System.getProperty("java.io.tmpdir"), dirResource.getFile().getAbsolutePath());
}

From source file:org.jasig.openregistry.core.repository.XmlSystemOfRecordRepository.java

/**
 * Creates a new repository using the supplied directory as the starting point.
 * //from   w w w .j  a v  a2  s .co  m
 * @param resource
 * @throws Exception
 */
public XmlSystemOfRecordRepository(final Resource resource) throws Exception {
    this.file = resource.getFile();
    logger.info("Attempting to load Xml Repository from [" + this.file.getAbsolutePath() + "]");
    Assert.isTrue(this.file.isDirectory(), "Provided resource MUST be a directory.");
    reload();
}

From source file:com.greglturnquist.springagram.fileservice.s3.DatabaseLoader.java

private void loadImage(String filename) throws IOException {
    Resource resource = ctx.getResource("classpath:" + filename);
    this.fileService.saveFile(resource.getInputStream(), resource.getFile().length(), filename);
}

From source file:it.geosolutions.geobatch.catalog.dao.file.xstream.FakeDataDirHandler.java

@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
    try {//from   ww w  . j a  v  a  2 s.  c o  m
        super.setApplicationContext(applicationContext);

        Resource resource = applicationContext.getResource("data");
        dataDirectory = resource.getFile();
        LOGGER.info("DATA DIR: " + dataDirectory);

    } catch (IOException ex) {
        throw new BeanInitializationException("Can't set data dir", ex);
    }
}