tags:

views:

452

answers:

2

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.

Thanks.

A: 

The Java API has a pretty good explanation of how to do that: http://java.sun.com/j2se/1.5.0/docs/api/java/net/URI.html

Without knowing what you are trying to do, I would use this constructor of URI: URI(String scheme, String authority, String path, String query, String fragment)

Chris J
That's what I was looking at. But it doesn't really fit the needs. Since it does nothing to verify the URI structure.
Sorantis
+1  A: 

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

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

See:

Mark Nottingham