How to clear a text file without deleting it using groovy

Viewed 9855

I've a text file which I'll be using it to write content.. But every time before I write something to the file, I wish to clear the content without deleting the file..

How would I achieve the above? Any suggestions?

3 Answers

With text files you can simply set it to an empty string.

file.text = ''
Related