我正在使用Java和Spring。
我正在获取一个MultiValueMap<String,String>。这对我很有帮助,因为我可以为每个key存储多个值。但是我正在使用的一个库需要一种Map<String,String[]>类型。更具体地说,我正在使用ParameterMap。如何执行这样的转换?
发布于 2019-01-18 02:11:18
获取地图的条目集并自己收集:
Map<String, String[]> result = map.entrySet()
.stream()
.collect(Collectors.toMap(
Map.Entry::getKey,
e -> e.getValue().toArray(new String[e.getValue().size()])
));https://stackoverflow.com/questions/54241759
复制相似问题