2

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 2

3

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

Sign up to request clarification or add additional context in comments.

Comments

-1

URLConnection has two direct subclasses:

All you need is look into the javadoc (links above).

1 Comment

URLConnection still allows more protocols than those two sub classes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.