Statistics
| Revision:

root / tmp / org.txm.groovy.core / src / groovy / org / txm / scripts / prototypes / WGet.groovy @ 1000

History | View | Annotate | Download (637 Bytes)

1
package org.txm.scripts.test
2

    
3
URL url = new URL("http://docs.codehaus.org/display/GROOVY/Simple+file+download+from+URL");
4
File outFile = new File("test.out")
5

    
6
static def download(def file, def url) {
7
                url.withInputStream() {is->
8
                         file.withOutputStream() {os->
9
                                 def bs = new BufferedOutputStream( os )
10
                                 bs << is
11
                         }
12
                 }
13
}
14

    
15
// if proxy , uncomment this and set up properties
16
//System.properties.putAll( ["http.proxyHost":"proxy-host",
17
//                                                         "http.proxyPort":"proxy-port",
18
//                                                         "http.proxyUserName":"user-name",
19
//                                                         "http.proxyPassword":"proxy-passwd"] )
20

    
21
WGet.download(outFile, url);
22
println outFile.getText()