Class UrlUtil


  • public final class UrlUtil
    extends java.lang.Object
    This file is a helper class for internal usage only. Be aware that its API and functionality may be changed in future.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private UrlUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String getFileUriString​(java.lang.String filename)
      This method gets uri string from a file.
      (package private) static java.net.URLConnection getFinalConnection​(java.net.URL initialUrl, int connectTimeout, int readTimeout)
      Gets the connection related to the last redirected url.
      static java.io.InputStream getInputStreamOfFinalConnection​(java.net.URL initialUrl)
      Gets the input stream of connection related to last redirected url.
      static java.io.InputStream getInputStreamOfFinalConnection​(java.net.URL initialUrl, int connectTimeout, int readTimeout)
      Gets the input stream of connection related to last redirected url.
      static java.lang.String getNormalizedFileUriString​(java.lang.String filename)
      This method gets normalized uri string from a file.
      static java.io.InputStream openStream​(java.net.URL url)  
      static java.lang.String toAbsoluteURI​(java.net.URI uri)
      Get the entire URI string which is properly encoded.
      static java.net.URI toNormalizedURI​(java.io.File file)
      This method makes a normalized URI from a given file.
      static java.net.URI toNormalizedURI​(java.lang.String filename)
      This method makes a normalized URI from a given filename.
      static java.net.URL toURL​(java.lang.String filename)
      This method makes a valid URL from a given filename.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • UrlUtil

        private UrlUtil()
    • Method Detail

      • toURL

        public static java.net.URL toURL​(java.lang.String filename)
                                  throws java.net.MalformedURLException
        This method makes a valid URL from a given filename.

        This method makes the conversion of this library from the JAVA 2 platform to a JDK1.1.x-version easier.

        Parameters:
        filename - a given filename
        Returns:
        a valid URL
        Throws:
        java.net.MalformedURLException - If a protocol handler for the URL could not be found, or if some other error occurred while constructing the URL
      • toNormalizedURI

        public static java.net.URI toNormalizedURI​(java.lang.String filename)
        This method makes a normalized URI from a given filename.
        Parameters:
        filename - a given filename
        Returns:
        a valid URI
      • toNormalizedURI

        public static java.net.URI toNormalizedURI​(java.io.File file)
        This method makes a normalized URI from a given file.
        Parameters:
        file - a given filename
        Returns:
        a valid URI
      • toAbsoluteURI

        public static java.lang.String toAbsoluteURI​(java.net.URI uri)
        Get the entire URI string which is properly encoded.
        Parameters:
        uri - URI which convert to string
        Returns:
        URI string representation
      • openStream

        public static java.io.InputStream openStream​(java.net.URL url)
                                              throws java.io.IOException
        Throws:
        java.io.IOException
      • getFileUriString

        public static java.lang.String getFileUriString​(java.lang.String filename)
                                                 throws java.net.MalformedURLException
        This method gets uri string from a file.
        Parameters:
        filename - a given filename
        Returns:
        a uri string
        Throws:
        java.net.MalformedURLException - If a protocol handler for the URL could not be found, or if some other error occurred while constructing the URL
      • getNormalizedFileUriString

        public static java.lang.String getNormalizedFileUriString​(java.lang.String filename)
        This method gets normalized uri string from a file.
        Parameters:
        filename - a given filename
        Returns:
        a normalized uri string
      • getInputStreamOfFinalConnection

        public static java.io.InputStream getInputStreamOfFinalConnection​(java.net.URL initialUrl)
                                                                   throws java.io.IOException
        Gets the input stream of connection related to last redirected url. You should manually close input stream after calling this method to not hold any open resources.
        Parameters:
        initialUrl - an initial URL.
        Returns:
        an input stream of connection related to the last redirected url.
        Throws:
        java.io.IOException - signals that an I/O exception has occurred.
      • getInputStreamOfFinalConnection

        public static java.io.InputStream getInputStreamOfFinalConnection​(java.net.URL initialUrl,
                                                                          int connectTimeout,
                                                                          int readTimeout)
                                                                   throws java.io.IOException
        Gets the input stream of connection related to last redirected url. You should manually close input stream after calling this method to not hold any open resources.
        Parameters:
        initialUrl - an initial URL.
        connectTimeout - a connect timeout in milliseconds.
        readTimeout - a read timeout in milliseconds.
        Returns:
        an input stream of connection related to the last redirected url.
        Throws:
        java.io.IOException - signals that an I/O exception has occurred.
      • getFinalConnection

        static java.net.URLConnection getFinalConnection​(java.net.URL initialUrl,
                                                         int connectTimeout,
                                                         int readTimeout)
                                                  throws java.io.IOException
        Gets the connection related to the last redirected url. You should close connection manually after calling this method, to not hold any open resources.
        Parameters:
        initialUrl - an initial URL.
        connectTimeout - a connect timeout in milliseconds.
        readTimeout - a read timeout in milliseconds.
        Returns:
        connection related to the last redirected url.
        Throws:
        java.io.IOException - signals that an I/O exception has occurred.