Class StandardURLStreamHandlerFactory

  • All Implemented Interfaces:
    java.net.URLStreamHandlerFactory

    public class StandardURLStreamHandlerFactory
    extends java.lang.Object
    implements java.net.URLStreamHandlerFactory
    Standard implementation of URLStreamHandlerFactory that creates a new instance of URLStreamHandler for a given protocol.

    This class uses reflection to access the internal JDK mechanism for retrieving the default factory since JDK 9+, and falls back to loading the handler class via its fully qualified name for JDK 8 and below.

    Example Usage

    
     URLStreamHandlerFactory factory = new StandardURLStreamHandlerFactory();
     URL.setURLStreamHandlerFactory(factory);
     

    This will allow the application to handle custom protocols by locating the appropriate URLStreamHandler implementation, typically in the package defined by URLUtils.DEFAULT_HANDLER_PACKAGE_PREFIX.

    Since:
    1.0.0
    Author:
    Mercy
    See Also:
    java.net.URL#getURLStreamHandler(String)
    • Constructor Detail

      • StandardURLStreamHandlerFactory

        public StandardURLStreamHandlerFactory()
    • Method Detail

      • createURLStreamHandler

        public java.net.URLStreamHandler createURLStreamHandler​(java.lang.String protocol)
        Specified by:
        createURLStreamHandler in interface java.net.URLStreamHandlerFactory