cancel
Showing results for 
Search instead for 
Did you mean: 

How to append data in existing file in groovy?

Highlighted
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
Highlighted
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
Highlighted
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:
Announcements
TechCorner Leaderboard
Want a fun and easy way to learn ReadyAPI and show off your skills? Try solving weekly TechCorner challenges and get into the Leaderboard!


Challenge Status

Compare an expected JSON value and actual response in Events

Participate!

Fetch value/data from JSON response using Groovy Script

See replies!

Filtering data retrieved from a DataSource

See replies!

Get data from Petstore and add it to Excel sheets

Participate!
Top Kudoed Authors