import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
private void saveUrlToFile(File saveFile, String location)
{
URL url;
try
{
url = new URL(location);
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
BufferedWriter out = new BufferedWriter(new FileWriter(saveFile));
char[] cbuf=new char[255];
while ((in.read(cbuf)) != -1) {
out.write(cbuf);
}
in.close();
out.close();
System.out.println("Done");
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
No hay comentarios:
Publicar un comentario