Example usage for org.springframework.core.io FileSystemResource getPath

List of usage examples for org.springframework.core.io FileSystemResource getPath

Introduction

In this page you can find the example usage for org.springframework.core.io FileSystemResource getPath.

Prototype

public final String getPath() 

Source Link

Document

Return the file path for this resource.

Usage

From source file:com.wavemaker.tools.project.LocalStudioFileSystem.java

@Override
public Resource createPath(Resource resource, String path) {
    Assert.isInstanceOf(FileSystemResource.class, resource, "Expected a FileSystemResource");
    try {//from w  w  w . java2 s .  co  m
        if (!resource.exists()) {
            File rootFile = resource.getFile();
            while (rootFile.getAbsolutePath().length() > 1 && !rootFile.exists()) {
                rootFile = rootFile.getParentFile();
            }
            IOUtils.makeDirectories(resource.getFile(), rootFile);
        }
        FileSystemResource relativeResource = (FileSystemResource) resource.createRelative(path);
        if (!relativeResource.exists()) {
            if (relativeResource.getPath().endsWith("/")) {
                IOUtils.makeDirectories(relativeResource.getFile(), resource.getFile());
            } else {
                IOUtils.makeDirectories(relativeResource.getFile().getParentFile(), resource.getFile());
            }
        }
        return relativeResource;
    } catch (IOException ex) {
        throw new WMRuntimeException(ex);
    }
}