Is there any way to print all supported URL schemes in Java8? I know Java8 supports http
, https
, file
etc. but what else is supported and will be correctly processed by URL.openStream()
method?
The javadoc for java.net.URL
states:
Protocol handlers for the following protocols are guaranteed to exist on the search path : http, https, file, and jar
Protocol handlers for additional protocols may also be available.
If you want more than http, https, file, and jar, you need to configure them yourself by writing and loading a Protocol Handler.
If the application has previously set up an instance of URLStreamHandlerFactory
as the stream handler factory, then the createURLStreamHandler
method of that instance is called with the protocol string as an argument to create the stream protocol handler.
If no URLStreamHandlerFactory
has yet been set up, or if the factory's createURLStreamHandler
method returns null, then the constructor finds the value of the system property: java.protocol.handler.pkgs
If the value of that system property is not null, it is interpreted as a list of packages separated by a vertical slash character '|'. The constructor tries to load the class named <package>.<protocol>.Handler
....where <package>
is replaced by the name of the package and <protocol>
is replaced by the name of the protocol. If this class does not exist, or if the class exists but it is not a subclass of URLStreamHandler
, then the next package in the list is tried.
<system default package>.<protocol>.Handler
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With