直接上例子:
public class URIMain { public static final String DEFAULT_BROKER_BIND_URL = "tcp://localhost:61616"; public static final String DEFAULT_BROKER_URL = "failover://"+DEFAULT_BROKER_BIND_URL; /** * @param args */ public static void main(String[] args) throws Exception{ String url="http://www.baidu.com?a=b&b=c"; String url1="http://127.0.0.1"; URI uri=new URI(url); System.out.println(uri.getScheme()); System.out.println(aauri.getHost()); System.out.println(uri.getPath()); System.out.println(uri.getQuery()); System.out.println(uri.getPort()); }}
打印结果:
www.baidu.com
a=b&b=c
-1