Is the URLConnection class capable of being subclassed to createcustom protocol connections?

?

-

Is the URLConnection class capable of being subclassed to create custom
protocol connections? Protocol in this case refers to ANY and ALL
protocol specified in RFC, e.g ftp, news, smtp, irc, nntp, and several
hundreds more or so....

If yes, should i use it or connect using the old fashion way of using
io/nio?
 
R

Raymond DeCampo

- said:
Is the URLConnection class capable of being subclassed to create custom
protocol connections? Protocol in this case refers to ANY and ALL
protocol specified in RFC, e.g ftp, news, smtp, irc, nntp, and several
hundreds more or so....

If yes, should i use it or connect using the old fashion way of using
io/nio?

I think you want a custom URLStreamHandler. See the javadoc for the URL
constructor

public URL(String protocol,
String host,
int port,
String file)
throws MalformedURLException

for configuration details.

HTH,
Ray
 
T

Thomas Fritsch

- said:
Is the URLConnection class capable of being subclassed to create custom
protocol connections? Protocol in this case refers to ANY and ALL
protocol specified in RFC, e.g ftp, news, smtp, irc, nntp, and several
hundreds more or so....
Yes (and the built-in protocols are implemented in exactly this manner)

See <http://doc.novsu.ac.ru/oreilly/java/exp/ch09_06.htm> for a real-world
example.
(This book is still very useful, although a bit out-dated. It wrote "package
net.www.protocol" where Sun now uses "package sun.net.www.protocol")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top