Created
March 26, 2019 02:46
-
-
Save bitfishxyz/58a072854e0cf4752eb910940114a955 to your computer and use it in GitHub Desktop.
Parse QueryString in Java with apache URLEncodedUtils
This file contains hidden or 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
import org.apache.http.NameValuePair; | |
import org.apache.http.client.utils.URLEncodedUtils; | |
import java.net.URI; | |
import java.util.List; | |
public class B { | |
public static void main(String[] args) throws Exception { | |
String url = "http://www.example.com/something.html" + | |
"?one=1&two=2&three=3&three=3a"; | |
List<NameValuePair> params = URLEncodedUtils.parse( | |
new URI(url), "UTF-8"); | |
for (NameValuePair param : params) { | |
System.out.println(param.getName() + " : " + param.getValue()); | |
} | |
} | |
} | |
// one : 1 | |
// two : 2 | |
// three : 3 | |
// three : 3a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Maven: