| 1 | package br.org.agilcoop.cursos.testes.unidade; |
| 2 | |
| 3 | import java.io.File; |
| 4 | import java.io.IOException; |
| 5 | import java.net.URL; |
| 6 | |
| 7 | public class WebUtils { |
| 8 | private URL url; |
| 9 | |
| 10 | public WebUtils(URL url) { |
| 11 | this.url = url; |
| 12 | } |
| 13 | |
| 14 | public File download(String path) throws IOException, InterruptedException { |
| 15 | String comando = "wget --quiet --no-cache " + url.toString() + "/" + path; |
| 16 | Process exec = Runtime.getRuntime().exec(comando); |
| 17 | exec.waitFor(); |
| 18 | String currentDir = System.getProperty("user.dir"); |
| 19 | String filename = path.replaceAll(".*/", ""); |
| 20 | return new File(currentDir + "/" + filename); |
| 21 | } |
| 22 | |
| 23 | public File upload(String path) { |
| 24 | return null; |
| 25 | } |
| 26 | } |