Groovy - File copy with substitution


/ Published in: Groovy
Save to your folder(s)

Write File while replacing from anothther


Copy this code and paste it in your HTML
  1. // copy with substitution
  2.  
  3. new File('new.txt').withWriter { file ->
  4. new File('orig.txt').eachLine { line ->
  5. file.writeLine( line.replace('code', 'joy') )
  6. }
  7. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.