XStream – Collection Converters

In the earlier tutorials we saw how to convert a Java object to XML and back, custom converter and basic converters. In this tutorial we look at how XStream converts array and collections from java to xml and vice versa. We will convert the following types :

  1. String[]
  2. char[]
  3. List&ltString&gt
  4. java.util.Properties
  5. List&ltString&gt
  6. Map&ltString, String&gt
  7. TreeMap&ltString, String&gt treeMap
  8. TreeSet&ltString&gt treeSet
  9. enum
  10. EnumMap&lttestEnum, String&gt testEnum is an enum
  11. EnumSet&lttestEnum&gt testEnum is an enum

Here’s the complete example

The resultant XML looks like this

Leave a Reply

Your email address will not be published. Required fields are marked *