@Deprecated
	public static String encodeUri(String uri, String encoding) throws UnsupportedEncodingException {
		Assert.notNull(uri, "URI must not be null");
		Assert.hasLength(encoding, "Encoding must not be empty");
		Matcher matcher = URI_PATTERN.matcher(uri);
		if (matcher.matches()) {
			String scheme = matcher.group(2);
			String authority = matcher.group(3);
			String userinfo = matcher.group(5);
			String host = matcher.group(6);
			String port = matcher.group(8);
			String path = matcher.group(9);
			String query = matcher.group(11);
			String fragment = matcher.group(13);
			return encodeUriComponents(scheme, authority, userinfo, host, port, path, query, fragment, encoding);
		}
		else {
			throw new IllegalArgumentException("[" + uri + "] is not a valid URI");
		}
	}
@ Deprecated public static String encodeUri ( String uri , String encoding ) throws UnsupportedEncodingException { Assert . notNull ( uri , "URI must not be null" ) ; Assert . hasLength ( encoding , "Encoding must not be empty" ) ; Matcher matcher = URI_PATTERN . matcher ( uri ) ; if ( matcher . matches ( ) ) { String scheme = matcher . group ( 2 ) ; String authority = matcher . group ( 3 ) ; String userinfo = matcher . group ( 5 ) ; String host = matcher . group ( 6 ) ; String port = matcher . group ( 8 ) ; String path = matcher . group ( 9 ) ; String query = matcher . group ( 11 ) ; String fragment = matcher . group ( 13 ) ; return encodeUriComponents ( scheme , authority , userinfo , host , port , path , query , fragment , encoding ) ; } else { throw new IllegalArgumentException ( "[" + uri + "] is not a valid URI" ) ; } }
Encodes the given source URI into an encoded String. All various URI components are
encoded according to their respective valid character sets.
<p><strong>Note</strong> that this method does not attempt to encode "=" and "&"
characters in query parameter names and query parameter values because they cannot
be parsed in a reliable way. Instead use:
<pre class="code">
UriComponents uriComponents = UriComponentsBuilder.fromUri("/path?name={value}").buildAndExpand("a=b");
String encodedUri = uriComponents.encode().toUriString();
</pre>
@param uri the URI to be encoded
@param encoding the character encoding to encode to
@return the encoded URI
@throws IllegalArgumentException when the given uri parameter is not a valid URI
@throws UnsupportedEncodingException when the given encoding parameter is not supported
@deprecated in favor of {@link UriComponentsBuilder}; see note about query param encoding