-
Notifications
You must be signed in to change notification settings - Fork 0
Philip Ford edited this page May 28, 2017
·
9 revisions
You can also get a File object (passing the path to the File constructor) and append text to it with a << operator:
new File('/Users/paford/Documents/test.txt') << 'Hello!'However, that method appends, what if you want to overwrite the file content completely?
Groovy provides a File.write() method that does that:
new File('config.json').write JsonOutput.prettyPrint(JsonOutput.toJson(json)) //json is a JSON string