When I do System.out.println(map)
in Java, I get a nice output in stdout. How can I obtain this same string representation of a Map
in a variable without meddling with standard output? Something like String mapAsString = Collections.toString(map)
?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
You can also use google-collections (guava) Joiner class if you want to customize the print format
Use
Object#toString()
.That's after all also what
System.out.println(object)
does under the hoods. The format for maps is described inAbstractMap#toString()
.