List of utility methods to do URL Download
File | download(String urlString) download StringBuffer sb = new StringBuffer(System.getProperty("java.io.tmpdir")).append(File.separator) .append(System.currentTimeMillis()).append(".jpg"); File outFile = new File(sb.toString()); URL url = null; OutputStream os = null; InputStream is = null; try { url = new URL(urlString); ... |
File | download(String urlString, File output) Download a file from a url to the local file system return download(urlString, output, false);
|
void | download(URL source, File destination) Downloads the file which is avaiable under the given source URL to the given destination File . InputStream inputStream = null; OutputStream outputStream = null; try { inputStream = source.openStream(); outputStream = new FileOutputStream(destination); outputStream.flush(); byte[] tempBuffer = new byte[4096]; int counter; ... |
void | download(URL sourceUrl, File destinationFile) This method given a URL sourceURL and file path destinationFile writes the contents of the URL to file. writeUrlToFile(sourceUrl, destinationFile); |
byte[] | download(URL url) download return download(url.toString(), 60000, 60000);
|
void | download(URL url, File destination) download byte[] buffer = new byte[4096]; int read, total = 0; URLConnection conn = url.openConnection(); conn.connect(); InputStream is = conn.getInputStream(); FileOutputStream out = new FileOutputStream(destination); while ((read = is.read(buffer)) > 0) { out.write(buffer, 0, read); ... |
void | download(URL url, File file) Downloads from the given url to the file without spamming the log. download(null, url, file); |
void | downloadAndExtract(String fileURL, String targetDirectory) download And Extract File file = downloadFile(fileURL, targetDirectory); unzip(file, targetDirectory); |
boolean | downloadAndSaveImage(URL imageUrl, String path) download And Save Image try { InputStream in; in = new BufferedInputStream(imageUrl.openStream()); ByteArrayOutputStream out = new ByteArrayOutputStream(); byte[] buf = new byte[1024]; int n = 0; while (-1 != (n = in.read(buf))) { out.write(buf, 0, n); ... |
void | downloadAndUnzip(String url, File location) download And Unzip InputStream in = null; FileOutputStream out = null; File archive = null; try { new File(location.getCanonicalPath()).mkdirs(); String archivePath = location.getCanonicalPath() + ARCHIVE_DOWNLOAD_NAME; archive = new File(archivePath); URL website = new URL((String) url); ... |