I am using snakeyaml to handle a yaml config file in Java.
My YAML file structure is this:
config.yml
User1: "John Doe"
User2: "Jane Smith"
User3: "James Doe"
When I do:
Yaml yaml = new Yaml();
Map<String, String> data = new HashMap<String, String>();
data.put("KR", "test");
String output = yaml.dump(data);
FileWriter f = new FileWriter("config.yml");
f.write(output);
Nothing is written to the config file.
I want to write my key values to the config.yml
file.
You don't seem to be closing your FileWriter. You might need to specify the path as well,
FileWriter f = new FileWriter("c:/config.yml"); // for c:\\config.yml
f.write(output);
f.close();