Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Groovy. Write objects to file (json) and read them back
package utils
import groovy.json.JsonBuilder
import groovy.json.JsonSlurper
class HDD {
static save(Object content, String filePath) {
new File(filePath).write(new JsonBuilder(content).toPrettyString())
static Object load(String filePath) {
return new JsonSlurper().parseText(new File(filePath).text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment