Posted By

hansamann on 01/05/07


Tagged

copy groovy


Versions (?)

Who likes this?

5 people have marked this snippet as a favorite

gwmccort
jsbournival
mbanfi
laurenceosx
michaelss


Copy File


 / Published in: Groovy
 

How to easily copy a file with Groovy. Two solutions: include a library like the Apache Commons (Net) or simply use ant (AntBuilder from Groovy code). Posted by Brian Pontarelli and Russel Winder

  1. //importjava.net commons
  2. FileTools.copyFile("foo.txt", "bar.txt");
  3.  
  4. //antbuilder (no import needed!)
  5. ( new AntBuilder ( ) ).copy ( file : 'blah' , tofile : 'fobar' )

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: olivernautsch on May 9, 2007

commons io works too

org.apache.commons.io.FileUtils.copyFile(srcfile, targetFile)
Posted By: artificialidea on July 5, 2007

You need to login to post a comment.