I need to download a file (this one for example: https://www.betaseries.com/srt/391160) so I have found different methods on the web:
def download(String remoteUrl, String localUrl)
{
def file = new FileOutputStream(localUrl)
def out = new BufferedOutputStream(file)
out << new URL(remoteUrl).openStream()
out.close()
}
or
def download(String remoteUrl, String localUrl) {
new File("$localUrl").withOutputStream { out ->
new URL(remoteUrl).withInputStream { from -> out << from; }
}
}
I see that the file is created but the file size is always equal to 1KB how can I fx it?
Thank in advance,
Benjamin