This library/wrapper handles file management elegantly.
In my experience doing operations on multiple file types, I found the need for a centralized library to handle this.
Using this library, you can read/write from any file type using the exact same syntax.
val pattern = YamlIOPattern()
val result = pattern.save(sample, path)
val pattern = YamlIOPattern()
val dataRead = pattern.load<SampleData>(path)
Refer to the unit tests for more examples of I/O