Kotlin Properties – Read/Write Properties from/to .properties/.XML File

In the post, we show how to Read/Write Properties from/to .Properties/.XML files by Kotlin language.

I. Kotlin – Read/Write Properties from/to .Properties file

1. Write Properties to .Properties file
1.1 Properties store() method

We use java.util.Properties.store() methods:

1.2 Kotlin Program – write Properties to .properties file

-> .properties output file:

2. Read Properties from .Properties file
2.1 Properties load() method

We use java.util.Properties.load() methods:

2.2 Kotlin Program – Read .Properties File to Properties object

II. Kotlin – Read/Write Properties from/to .XML file

1. Write Properties to .XML file
1.1 Properties.storeToXML() method

We use java.util.Properties.storeToXML() methods:

1.2 Kotlin Program – Write Properties object to XML file

-> .xml output file:

2. Read Properties from .XML file
2.1 Properties.loadFromXML() method

We use java.util.Properties.loadFromXML() method:

2.2 Kotlin Program – Read XML file to Properties object

By JavaSampleApproach | March 7, 2018.

Related Posts


Got Something To Say:

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

*