Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  
  package sk.seges.sesam.spring.core.io;
  
  import java.io.File;
 import java.net.URL;
 

Author(s):
eldzi
 
 public class RelativeFileSystemResource extends AbstractResource {
     private final File file;
 
     private final String path;
 
     public RelativeFileSystemResource(String propertyString path) {
     	this(propertypathfalse);
     }
    
    
Create a new FileSystemResource.

Parameters:
path a file path
 
     public RelativeFileSystemResource(String propertyString pathboolean environment) {
         Assert.notNull(path"Path must not be null");
         this. = new File(getProperty(propertyenvironment), path);
         this. = StringUtils.cleanPath(path);
     }
 
     private File getProperty(String propertyboolean environment) {
         String propertyValue;
         if(environment)
         	propertyValue = System.getenv(property);
         else
         	propertyValue = System.getProperty(property);
         
         if(propertyValue == null)
             throw new IllegalStateException("Property (environment = " + environment + " ) " + property + " was not set!");
         return new File(propertyValue);
     }
    
    
Return the file path for this resource.
 
     public final String getPath() {
         return ;
     }


    
This implementation returns whether the underlying file exists.

 
     public boolean exists() {
         return this..exists();
     }

    
This implementation opens a FileInputStream for the underlying file.

 
     public InputStream getInputStream() throws IOException {
         return new FileInputStream(this.);
     }

    
This implementation returns a URL for the underlying file.

 
     public URL getURL() throws IOException {
         return new URL(. + this..getAbsolutePath());
     }

    
This implementation returns the underlying File reference.
 
     public File getFile() {
         return ;
     }

    
This implementation creates a FileSystemResource, applying the given path relative to the path of the underlying file of this resource descriptor.

 
     public Resource createRelative(String relativePath) {
         String pathToUse = StringUtils.applyRelativePath(this.relativePath);
         return new FileSystemResource(pathToUse);
    }

    
This implementation returns the name of the file.

    public String getFilename() {
        return this..getName();
    }

    
This implementation returns a description that includes the absolute path of the file.

    public String getDescription() {
        return "file [" + this..getAbsolutePath() + "]";
    }


    
This implementation compares the underlying File references.
    public boolean equals(Object obj) {
        return (obj == this ||
            (obj instanceof RelativeFileSystemResource && this..equals(((RelativeFileSystemResourceobj).)));
    }

    
This implementation returns the hash code of the underlying File reference.
    public int hashCode() {
        return this..hashCode();
    }
New to GrepCode? Check out our FAQ X