Class UrlResource

    • Constructor Detail

      • UrlResource

        public UrlResource​(URL url)
        Create a new UrlResource based on the given URL object.
        Parameters:
        url - a URL
      • UrlResource

        public UrlResource​(String path)
                    throws MalformedURLException
        Create a new UrlResource based on a URL path.

        Note: The given path needs to be pre-encoded if necessary.

        Parameters:
        path - a URL path
        Throws:
        MalformedURLException - if the given URL path is not valid
        See Also:
        URL(String)
      • UrlResource

        public UrlResource​(String protocol,
                           String location)
                    throws MalformedURLException
        Create a new UrlResource based on a URI specification.

        The given parts will automatically get encoded if necessary.

        Parameters:
        protocol - the URL protocol to use (e.g. "jar" or "file" - without colon); also known as "scheme"
        location - the location (e.g. the file path within that protocol); also known as "scheme-specific part"
        Throws:
        MalformedURLException - if the given URL specification is not valid
        See Also:
        URI(String, String, String)
      • UrlResource

        public UrlResource​(String protocol,
                           String location,
                           String fragment)
                    throws MalformedURLException
        Create a new UrlResource based on a URI specification.

        The given parts will automatically get encoded if necessary.

        Parameters:
        protocol - the URL protocol to use (e.g. "jar" or "file" - without colon); also known as "scheme"
        location - the location (e.g. the file path within that protocol); also known as "scheme-specific part"
        fragment - the fragment within that location (e.g. anchor on an HTML page, as following after a "#" separator)
        Throws:
        MalformedURLException - if the given URL specification is not valid
        See Also:
        URI(String, String, String)