Class FileSystemResource

    • Constructor Detail

      • FileSystemResource

        public FileSystemResource​(File file)
        Create a new FileSystemResource from a File handle.

        Note: When building relative resources via createRelative(java.lang.String), 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
      • FileSystemResource

        public FileSystemResource​(String path)
        Create a new FileSystemResource from a file path.

        Note: When building relative resources via createRelative(java.lang.String), 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