Friday, October 24, 2014

Easy peasy file/URL binary downloading with Ant get

def ant = new AntBuilder()
ant.get(src: 'http://groovy.codehaus.org/a.jpg', dest: /C:\scrap\a.jpg/, skipexisting: 'true')

//or 

File destFile = new File(dest)
if (destFile.exists()) return
destFile.withOutputStream { it << src.toURL().openStream() }