从URL查询字符串中提取地图。
import java.util.Arrays; import java.util.Collection; import java.util.HashMap; /*来自 时 代 Java - nowjava.com*/ import java.util.HashSet; import java.util.Map; import java.util.Properties; import java.util.Set; import java.util.TreeSet; public class Main{ public static void main(String[] argv) throws Exception{ String query = "nowjava.com"; System.out.println(extractMap(query)); } /** * Extract a map from a query string. * * @param query a query (or fragment) string from a URI * @return a Map of the values in the query */ public static Map<String, String> extractMap(String query) { Map<String, String> map = new HashMap<String, String>(); Properties properties = StringUtils/**from 时代Java - N o w J a v a . c o m**/ .splitArrayElementsIntoProperties( StringUtils.delimitedListToStringArray(query, "&"),