Best way to store Country codes, names, and Continent in Java

后端 未结 5 975
Happy的楠姐
Happy的楠姐 2021-02-03 13:30

I want to have a List or Array of some sort, storing this information about each country:

  • 2 letter code
  • Country name such as Br
5条回答
  •  离开以前
    2021-02-03 14:16

    The easiest way to do this is to create the country/continent structure in Java using a map (or whatever collection) and then persist it using XStream

    This will create an XML representation of the collection, and you can read than into your process very easily and convert it back to the same collection type that you initially created. Furthermore, because it's XML, you can easily edit it outside of code. i.e. just in a text editor.

    See the XStream tutorial for more info.

提交回复
热议问题