Encode and Decode rfc2396 URLs
问题 What is the best way to encode URL strings such that they are rfc2396 compliant and to decode a rfc2396 compliant string such that for example %20 is replaced with a space character? edit: URLEncoder and URLDecoder classes do not encode/decode rfc2396 compliant URLs, they encode to a MIME type of application/x-www-form-urlencoded which is used to encode HTML form parameter data. 回答1: Use the URI class as follows: URI uri = new URI("http", "//www.someurl.com/has spaces in url", null); URL url