Java 8: How to convert String to Map<String,String>?
问题 I have a Map: Map<String, String> utilMap = new HashMap(); utilMap.put("1","1"); utilMap.put("2","2"); utilMap.put("3","3"); utilMap.put("4","4"); I converted it to a String: String utilMapString = utilMap .entrySet() .stream() .map(e -> e.toString()).collect(Collectors.joining(",")); Out put: 1=1,2=2,3=3,4=4,5=5 How to convert utilMapString to Map in Java8? Who can help me with? 回答1: Split the string by , to get individual map entries. Then split them by = to get the key and the value. Map