Guest User

Untitled

a guest
May 26th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. public abstract class UriUtils {
  2.  
  3. // ...
  4.  
  5. public static String encodeUri(String uri, String encoding) throws UnsupportedEncodingException {
  6. String query = UriComponentsBuilder.fromUriString(uri).build().getQuery();
  7. String encodedQuery = UriUtils.encodeQuery(query, encoding);
  8.  
  9. UriComponents uriComponents = UriComponentsBuilder.fromUriString(uri).build();
  10. UriComponents encoded = uriComponents.encode(encoding);
  11. UriComponents updated = UriComponentsBuilder.fromUriString(encoded.toString()).replaceQuery(encodedQuery).build();
  12.  
  13. return updated.toUriString();
  14. }
  15.  
  16. // ...
  17.  
  18. }
Add Comment
Please, Sign In to add comment