Class Urls


  • public class Urls
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.net.URI from​(java.lang.String rawUri)
      Convert a string, which may just be a hostname, into a valid URI.
      static java.net.URL fromUri​(java.net.URI uri)  
      static java.lang.String urlEncode​(java.lang.String value)
      Encodes the text as an URL using UTF-8.
      • Methods inherited from class java.lang.Object

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

      • urlEncode

        public static java.lang.String urlEncode​(java.lang.String value)
        Encodes the text as an URL using UTF-8.
        Parameters:
        value - the text too encode
        Returns:
        the encoded URI string
        See Also:
        URLEncoder.encode(java.lang.String, java.lang.String)
      • fromUri

        public static java.net.URL fromUri​(java.net.URI uri)
      • from

        public static java.net.URI from​(java.lang.String rawUri)
        Convert a string, which may just be a hostname, into a valid URI. If no scheme is given, it is set to http by default.

        We prefer to use URI instead of URL since the latter requires a scheme handler to be registered for types, so strings like docker://localhost:1234 would not generally be a valid URL but would be a correct URI.

        A known limitation is that URI fragments are not handled. In the expected use cases for this method, that is not a problem.