What is a good method of persisting application properties?

前端 未结 8 1967
不思量自难忘°
不思量自难忘° 2021-01-05 09:43

I have a series of application properties which all have different types.

The types could include, booleans, dates, timestamps, or strings.

I need to be abl

8条回答
  •  情话喂你
    2021-01-05 10:29

    java.util.Properties is the easiest way. A Properties object can be created from a properties file (a file containing properties in the format name=value) or even a simple XML file. You can modify the object in memory and then write it back to a properties or XML file.

    If you need more flexibility in structuring the properties, you can consider designing your own XML configuration file, although it will be a bit more work to read and write. You can however use a marshalling/unmarshalling API like JAXB, XStream etc to make that task easier.

    These files can easily be modified manually as well.

提交回复
热议问题