Created
August 4, 2014 10:34
-
-
Save keyle/723181f3a9a59a3f7652 to your computer and use it in GitHub Desktop.
Groovy. Write objects to file (json) and read them back
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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