开发者

Creating custom URI scheme using URI class

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

u开发者_运维知识库rn: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.


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

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

See:

  • http://infomesh.net/2001/09/urischemes
  • https://www.w3.org/TR/webarch/#URI-scheme
  • https://www.rfc-editor.org/rfc/rfc4395


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)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜