| 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 | 0 | public WebUtils(URL url) { |
| 11 | 0 | this.url = url; |
| 12 | 0 | } |
| 13 | |
|
| 14 | |
public File download(String path) throws IOException, InterruptedException { |
| 15 | 0 | String comando = "wget --quiet --no-cache " + url.toString() + "/" + path; |
| 16 | 0 | Process exec = Runtime.getRuntime().exec(comando); |
| 17 | 0 | exec.waitFor(); |
| 18 | 0 | String currentDir = System.getProperty("user.dir"); |
| 19 | 0 | String filename = path.replaceAll(".*/", ""); |
| 20 | 0 | return new File(currentDir + "/" + filename); |
| 21 | |
} |
| 22 | |
|
| 23 | |
public File upload(String path) { |
| 24 | 0 | return null; |
| 25 | |
} |
| 26 | |
} |