Class ExternalResource

    • Field Detail

      • file

        private final java.io.File file
    • Constructor Detail

      • ExternalResource

        public ExternalResource​(java.lang.String path)
        Constructor
        Parameters:
        path - the path to the external resource
    • Method Detail

      • isDirectory

        public boolean isDirectory()
        Tests whether the file denoted by this abstract pathname is a directory.
        Returns:
        true if and only if the file denoted by this abstract pathname exists and is a directory; false otherwise
      • exists

        public boolean exists()
        Description copied from class: AbstractResource
        This implementation checks whether a File can be opened, falling back to whether an InputStream can be opened. This will cover both directories and content resources.
        Specified by:
        exists in interface Resource
        Overrides:
        exists in class AbstractFileResolvingResource
        Returns:
        if exists
      • getDescription

        public java.lang.String getDescription()
        Returns:
        a description for this resource, to be used for error output when working with the resource.

        Implementations are also encouraged to return this value from their toString method.

        See Also:
        Object.toString()
      • getInputStream

        public java.io.InputStream getInputStream()
                                           throws java.io.IOException
        Description copied from interface: InputStreamResource
        Return an InputStream.

        It is expected that each call creates a fresh stream.

        This requirement is particularly important when you consider an API such as JavaMail, which needs to be able to read the stream multiple times when creating mail attachments. For such a use case, it is required that each getInputStream() call returns a fresh stream.

        Returns:
        the input stream for the underlying resource (must not be null)
        Throws:
        java.io.IOException - if the stream could not be opened
      • getURL

        public java.net.URL getURL()
                            throws java.io.IOException
        This implementation returns a URL for the underlying class path resource.
        Specified by:
        getURL in interface Resource
        Overrides:
        getURL in class AbstractResource
        Returns:
        a URL handle for this resource.
        Throws:
        java.io.IOException - if the resource cannot be resolved as URL, i.e. if the resource is not available as descriptor
        See Also:
        ClassLoader.getResource(String), Class.getResource(String)
      • getPath

        public java.lang.String getPath()
        Gets the path
        Returns:
        the path