Example #1
0
 /**
  * Create a new FileSystemResource from a File handle.
  *
  * <p>Note: When building relative resources via {@link #createRelative}, the relative path will
  * apply <i>at the same directory level</i>: 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 {@link #FileSystemResource(String) 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.
  *
  * @param file a File handle
  */
 public FileSystemResource(File file) {
   Assert.notNull(file, "File must not be null");
   this.file = file;
   this.path = Str.cleanPath(file.getPath());
 }
Example #2
0
 /**
  * Create a new FileSystemResource from a file path.
  *
  * <p>Note: When building relative resources via {@link #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".
  *
  * @param path a file path
  */
 public FileSystemResource(String path) {
   Assert.notNull(path, "Path must not be null");
   this.file = new File(path);
   this.path = Str.cleanPath(path);
 }
Example #3
0
 /**
  * This implementation creates a FileSystemResource, applying the given path relative to the path
  * of the underlying file of this resource descriptor.
  *
  * @see org.Str.util.Strings#applyRelativePath(String, String)
  */
 public Resource createRelative(String relativePath) {
   String pathToUse = Str.applyRelativePath(this.path, relativePath);
   return new FileSystemResource(pathToUse);
 }