Carleslc / Simple-YAML

This Java API provides an easy-to-use way to store data and provide configurations using the YAML format.
https://carleslc.me/Simple-YAML
GNU General Public License v3.0
130 stars 38 forks source link

How can I use defaults? #5

Closed noobidev closed 5 years ago

noobidev commented 5 years ago

Hi, I added some keys and values to the default map, but they have not been added to this file. So how can I use them for pre-set my yml file? Sorry for my bad English :)

Carleslc commented 5 years ago

Default values are only stored in memory if options().copyDefaults() is set to false. This option is set to false by default, but is set to true on load().

You can enable copying the default options with:

yamlFile.options().copyDefaults(true);

Another option is to use yamlFile.load() after creating the file with yamlFile.createNewFile(true) the first time. I've updated the YamlTest.java file using this behavior.

noobidev commented 5 years ago

Thank you!