cancel
Showing results for 
Search instead for 
Did you mean: 

How to append data in existing file in groovy?

Frequent Contributor

How to append data in existing file in groovy?

Hi:

Java can append data to a file using FileOutputStream or Filewriter.  Does groovy have a similar API? 


I found one of the threads that you posted previously which allowed us to save a soap response to an external file.  Again, I want to save multiple runs of the same request so I can capture ALL requests/responses (this is very important for me in debugging).

def msg = context.getProperty( "request-step#Response" )
new File( "testout.txt" ).write( msg )

Do you think it is possible using something similar to FileOutputStream/Filewriter to append all latter requests/responses to the first run?

Thanks,
Li Zhang
2 REPLIES 2
Super Contributor

Re: How to append data in existing file in groovy?

Hi!

the groovy reference card at http://docs.codehaus.org/download/attac ... on=1  lists a file.append method.. try

new File( "testout.txt" ).append( msg )

instead!?

Hope this helps!

regards,

/Ole
eviware.com
Frequent Contributor

Re: How to append data in existing file in groovy?

It works perfectly.

Thanks a lot.

Li
New Here?
Join us and watch the welcome video:
Top Kudoed Authors