Created
July 23, 2016 14:49
-
-
Save nobodyiam/420b9fab2c2f6d477ae1b73400961506 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Escaper pathEscapers = UrlEscapers.urlPathSegmentEscaper(); | |
Escaper queryEscapers = UrlEscapers.urlFormParameterEscaper(); | |
Escaper fragmentEscaper= UrlEscapers.urlFragmentEscaper(); | |
String path1 = "somePathWithSpace "; | |
String path2 = "somePathWith中文AndPlus+"; | |
String someKeyword = "someKeywordWith中文AndPlus+AndSpace "; | |
String someFragment = "someFragmentWithSpace "; | |
String url = String.format( | |
"http://example.com/%s/%s?keyword=%s#%s", | |
pathEscapers.escape(path1), | |
pathEscapers.escape(path2), | |
queryEscapers.escape(someKeyword), | |
fragmentEscaper.escape(someFragment)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment