public static int getSize(URI uri, String proxyHost, Integer proxyPort) { try { if (uri.getScheme().equals(PROTOCOL_HTTP)) { WebResource resource = new WebResource(uri, proxyHost, proxyPort); int size = resource.getSize(); resource.shutdown(); return size; } return uri.toURL().openConnection().getContentLength(); } catch (IOException e) { return 0; } }
WebResource resource = new WebResource(uri, proxyHost, proxyPort); long time = resource.getLastModified(); resource.shutdown(); return time;
/** * @param job * @param uri * @param dest * @throws LucidException */ private void copy(Progress job, URI uri, URI dest) throws LucidException { if (job != null) { // TRANSLATOR: Progress label for downloading one or more files. job.setSectionName(JSMsg.gettext("Downloading files")); } WebResource wr = new WebResource(uri, proxyHost, proxyPort); wr.copy(dest, job); wr.shutdown(); }
private void copy(Progress job, URI source, URI dest) throws InstallException { Log.d(TAG, "Downloading "+source+" to "+dest); if (job != null) { // TRANSLATOR: Progress label for downloading one or more files. job.setSectionName(JSMsg.gettext("Downloading files")); } // last 2 params are proxies which I hope we can ignore on Android WebResource wr = new WebResource(source, null, null); try { wr.copy(dest, job); } catch (LucidException le) { // TRANSLATOR: Common error condition: {0} is a placeholder for the URL of what could not be found. throw new InstallException(JSMsg.gettext("Unable to find: {0}", source.toString()), le); } finally { wr.shutdown(); } } }