Save This Page
Home » spring-framework-2.5.5-with-dependencies » org.springframework » core » io » [javadoc | source]
org.springframework.core.io
public class: FileSystemResource [javadoc | source]
java.lang.Object
   org.springframework.core.io.AbstractResource
      org.springframework.core.io.FileSystemResource

All Implemented Interfaces:
    Resource

Direct Known Subclasses:
    FileSystemContextResource

Resource implementation for java.io.File handles. Obviously supports resolution as File, and also as URL.
Constructor:
 public FileSystemResource(File file) 
    Create a new FileSystemResource from a File handle.

    Note: When building relative resources via #createRelative , the relative path will apply at the same directory level: e.g. new File("C:/dir1"), relative path "dir2" -> "C:/dir2"! If you prefer to have relative paths built underneath the given root directory, use the constructor with a file path to append a trailing slash to the root path: "C:/dir1/", which indicates this directory as root for all relative paths.

    Parameters:
    file - a File handle
 public FileSystemResource(String path) 
    Create a new FileSystemResource from a file path.

    Note: When building relative resources via #createRelative , it makes a difference whether the specified resource base path here ends with a slash or not. In the case of "C:/dir1/", relative paths will be built underneath that root: e.g. relative path "dir2" -> "C:/dir1/dir2". In the case of "C:/dir1", relative paths will apply at the same directory level: relative path "dir2" -> "C:/dir2".

    Parameters:
    path - a file path
Method from org.springframework.core.io.FileSystemResource Summary:
createRelative,   equals,   exists,   getDescription,   getFile,   getFilename,   getInputStream,   getPath,   getURI,   getURL,   hashCode,   isReadable
Methods from org.springframework.core.io.AbstractResource:
createRelative,   equals,   exists,   getFile,   getFileForLastModifiedCheck,   getFilename,   getURI,   getURL,   hashCode,   isOpen,   isReadable,   lastModified,   toString
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.springframework.core.io.FileSystemResource Detail:
 public Resource createRelative(String relativePath) 
    This implementation creates a FileSystemResource, applying the given path relative to the path of the underlying file of this resource descriptor.
 public boolean equals(Object obj) 
    This implementation compares the underlying File references.
 public boolean exists() 
    This implementation returns whether the underlying file exists.
 public String getDescription() 
    This implementation returns a description that includes the absolute path of the file.
 public File getFile() 
    This implementation returns the underlying File reference.
 public String getFilename() 
    This implementation returns the name of the file.
 public InputStream getInputStream() throws IOException 
    This implementation opens a FileInputStream for the underlying file.
 public final String getPath() 
    Return the file path for this resource.
 public URI getURI() throws IOException 
    This implementation returns a URI for the underlying file.
 public URL getURL() throws IOException 
    This implementation returns a URL for the underlying file.
 public int hashCode() 
    This implementation returns the hash code of the underlying File reference.
 public boolean isReadable() 
    This implementation checks whether the underlying file is marked as readable (and corresponds to an actual file with content, not to a directory).