zot24
5/16/2014 - 7:42 AM

How to write content to a new file (overwrite if already existing) in Groovy.

How to write content to a new file (overwrite if already existing) in Groovy.

//
// Write the mock request payload to a file for checking later...
// newWrite() is the important it to ensure you get a *new* file each time.
//
def filename = "C:\\MyScratchFolder\\soapUI projects\\Testing\\procon\\mock_po_activity_request.xml"
def file = new File(filename)
def w = file.newWriter() 

w << mockRequest.requestContent
w.close()