List of utility methods to do URL Download
void | downloadMobiFromEpubUrl(String href) download Mobi From Epub Url URL urlEpub = new URL(href); String path = urlEpub.getFile(); path = path.substring(0, path.length() - 4).concat("mobi"); URL urlMobi = new URL("http", "bb.bulexpo-bg.com", path); InputStream in = urlMobi.openStream(); String fileName = path.substring(path.lastIndexOf('/') + 1); downloadBook(in, fileName); |
String | downloadPageSource(String stringURL) download Page Source URL url; HttpURLConnection conn; StringBuilder source = new StringBuilder(); try { url = new URL(stringURL); conn = (HttpURLConnection) url.openConnection(); } catch (IOException ex) { throw ex; ... |
void | downloadSource(PrintStream out, PrintStream err, String srcURL, String dirStr, boolean extract) download Source String fileName = (srcURL.lastIndexOf('/') > 0) ? srcURL.substring(srcURL.lastIndexOf('/') + 1) : srcURL; try { out.println("Connecting..."); File dir = new File(dirStr); if (!dir.exists()) { err.println("Destination directory does not exist."); File file = new File(dir, fileName); ... |
String | downloadString(String url) download String String s = null; try { BufferedReader reader = new BufferedReader(new InputStreamReader(new URL(url).openStream())); String ss; while ((ss = reader.readLine()) != null) s += ss; } catch (IOException ex) { ex.printStackTrace(); ... |
String | downloadString(URL url) download String return readString(url.openStream());
|
String | downloadString(URL url) Downloads data from the given URL and returns it as a string. return readString(url.openStream());
|
String | downloadText(String url) Download text from a string url. return downloadText(new URL(url)); |
String | downloadTextFromUrl(String url) Downloads text from a given URL and returns it as a String InputStream in; try { in = new URL(url).openStream(); Scanner scan = new Scanner(in); return scan.hasNext() ? scan.next() : null; } catch (MalformedURLException e) { e.printStackTrace(); return null; ... |
long | downloadTo(String url, String filename) download To URL httpUrl = new URL(url); File file = new File(filename); file.deleteOnExit(); if (file.exists()) { if (file.isDirectory()) { throw new IOException("File '" + file + "' exists but is a directory"); if (file.canWrite() == false) { ... |
String | downloadToDirectory(URL url, String directoryName) Utility to download a remote file from a URL and place the contents into a directory. BufferedInputStream inputStream = new BufferedInputStream(url.openStream()); String pathname = url.getPath(); String filename = pathname; int index = pathname.lastIndexOf("/"); if (index != -1) { filename = pathname.substring(index + 1); int bytes; ... |