1

Does java standard lib have a class to parse a URL string with query string(parameters)? e.g.,

URL url = new URL(urlString);
Map<String,String> parameters = url.getParameters();
String value = url.getParameter(name);

But the standard URL class does not have knowledge of query string parameters.

eastwater
  • 4,624
  • 9
  • 49
  • 118
  • 1
    Nope. No such method exists at the moment. There’s open bugs for it, such as https://bugs.java.com/bugdatabase/view_bug.do?bug_id=6794192 and https://bugs.java.com/bugdatabase/view_bug.do?bug_id=6306820. – VGR Sep 21 '19 at 02:54
  • If you decide to implement this yourself, note that the same parameter may appear in the query string multiple times. A better return type might be `Map>` (or if you're lucky enough to be using Guava, `Multimap`). – dnault Sep 21 '19 at 05:11
  • This anwser may help you: [parse-a-uri-string-into-name-value-collection](https://stackoverflow.com/questions/13592236/parse-a-uri-string-into-name-value-collection) – Eelco Jul 24 '20 at 12:12

0 Answers0