YAML file editing

I was wondering if there was a way to edit a YAML file and save the edited version…
So it would be something like this maybe:

File yaml = new File(System.getProperty("user.home") + "/Desktop/*.*");
selectInput("Choose File", "fileSelected",yaml);
yaml.set("data.materials.example", "random string");
pconfig.save(panelsf);

and so the yaml file saved would be something like:

data:
  materials:
    example: 'random string'

so I wanted to be able to get a yaml file, convert it to something like a YAMLConfiguration, edit it and save it, edited.

1 Like

I don’t thing java and processing are particularly friendly with yaml, ruby and JRubyArt are however. In my examples in JRubyArt I use the yaml gem which is easy to use and does exactly what you expect.
sketch

library

1 Like

I also found this library that I downloaded https://www.baeldung.com/java-snake-yaml
I use the Bukkit API for other projects, (this one is linking with them). Bukkit uses that so maybe it would be something to use.
EDIT:
I was able to use the Bukkit library in itself and snake yaml.
if anyone in the future needs to use yaml file editing, Bukkit has good support for it.
http://www.java2s.com/Code/Jar/b/Downloadbukkitjar.htm

If someone came to this thread for the answer, I just downloaded spigot/bukkit and used it’s jar file as a library.

2 Likes