Skip to content
Advertisement

Creating custom URI scheme using URI class

I need to create a custom URI scheme for my project. i.e

urn:myprotocol:{p1}:{p2}:{p3}:{p4} – opaque representation

myprotocol://{p1}/{p2}/{p3}/{p4} – hierarchical representation.

How can I add my scheme to Java URI class? Or, how can I make Java URI to understand my scheme, so I could use it in my code?

Concrete examples are welcome.

Advertisement

Answer

Are you sure you need to create a new URI scheme?

It’s considered bad practice to create implementation-specific schemes.

See:

Advertisement