Skip to content

Instantly share code, notes, and snippets.

@keyle
Created August 4, 2014 10:34
Show Gist options
  • Save keyle/723181f3a9a59a3f7652 to your computer and use it in GitHub Desktop.
Save keyle/723181f3a9a59a3f7652 to your computer and use it in GitHub Desktop.
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