Where can I get all the details about the protocols we can use in java to make a URL connection. like : for jar its jar:file:///c|/!/ what does this notaion mean ? what wd be for let's say nntp, telnet or ftp kind of protocols. does sun provides any documentation ?
2 Answers
The only thing that is fixed is the specification laid out in RFC3986 (http://tools.ietf.org/html/rfc3986#section-1.1.1) . For the different protocols Java uses differen java.net.URLStreamHandlers. These are found dynamically at runtime
You can even register a custom URLStramHandlerFactory for own protocols. The different handlers are chosen dynamically when using URL.openConnection()
Default handlers available in JDK are in sub-packages of sun.net.www.protocol and classes are named Handler, i.e. sun.net.www.protocol.jar.Handler is for jar protocol and sun.net.www.protocol.mailto.Handler is for mailto.
Available protocols are:
- FTP
- jar
- netdoc
- file
- gopher
- mailto
- http
- https
For each of the protocols the according RFC specifies the exact URI syntax
Comments
URLConnection has two direct subclasses:
All you need is look into the javadoc (links above).