HttpClient中URI和URL之间的区别是什么

时间:2013-07-12 00:31:55

标签: url uri apache-httpclient-4.x

在下面的示例代码中,uri何时不等于url?

HttpClient client = new DefaultHttpClient();
String url = "http://domain/path1/path2"
HttpGet get = new HttpGet(toFetchURL);
HttpResponse response = client.execute(get);

String uri = get.getURI.toString();
if (!uri.equals(url)) {
    // when would this happen?
    // some logic
}

1 个答案:

答案 0 :(得分:0)

URL是URI的子集。所以URL可以转换为URI,但URI不能转换为URL。