更新时间:2022-02-17 05:24:32
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
public static Map<String, String> maptoMapString(Map<String, ?> map) {
return map.entrySet().stream().collect(Collectors.toMap(
(entry) -> {
return entry.getKey();
},
(entry) -> {
if (entry.getValue().getClass().isArray()) {
StringBuilder sb = new StringBuilder();
for ( int i= 0 ; i<Array.getLength(entry.getValue()); ++i) {
Object obj = Array.get(entry.getValue(), i);
sb.append(obj.toString()).append( "," );
}
if (sb.length() > 0 ) {
sb.deleteCharAt(sb.length() - 1 );
}
return sb.toString();
} else {
return entry.getValue().toString();
}
}
));
} |