You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register

Groovy features to write to file

Received Response
357
Views
3
Comments

Summary:


Content (required):

I've noticed that Groovy provides various methods to write to files such as CSVWriter and CreateFilePrintWriter.

As I understand, both these methods create a new file or overwrite an existing file that matches the name provided in the parameter.

Rather than creating a new file each time the method is called, what I am looking for is a method that allows us to append lines of text to an existing file.

For example, is it possible to have a groovy script that writes to a file as follows:

createFilePrintWriter("test.txt"){out->
 out.println "hello"
}




Then have some more groovy script that appends more text to the same file

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!