List of utility methods to do URL Load
String | readUrlContent(String address) read Url Content StringBuilder contents = new StringBuilder(2048); BufferedReader br = null; try { URL url = new URL(address); br = new BufferedReader(new InputStreamReader(url.openStream())); String line; while ((line = br.readLine()) != null) { contents.append(line); ... |
String | readURLContents(String UrlText) read URL Contents try { InputStream in = openURLStream(UrlText); String page = readStream(in); return (page); } catch (IOException ex) { throw new IllegalArgumentException(ex.toString()); |
JSONArray | readURLJSONArray(String urlString) read URLJSON Array try { return new JSONArray(readURL(urlString)); } catch (JSONException e) { return null; |
Properties | readUrlProperties(URL url) read Url Properties Properties returnProperties = new Properties(); if (url != null) { BufferedReader reader = null; try { reader = new BufferedReader(new InputStreamReader(url.openStream())); returnProperties.load(reader); } finally { if (reader != null) { ... |
String | readUrlStream(String urlString) Read, as a string, the stream at the given url string. URL url = new URL(urlString); InputStream stream = url.openStream(); return toString(stream); |
String | readUrlText(final URL url, final String encoding) reads the content from the given URL using the given character encoding. InputStream in; try { in = url.openStream(); } catch (IOException e) { throw new IOException("Could not open stream for URL '" + url + "': " + e, e); Scanner scanner = new Scanner(in, encoding); scanner.useDelimiter("\\A"); ... |
String | readURLText(String urlPath, String encoding) read URL Text BufferedReader br = null; try { URL url = new URL(urlPath); br = new BufferedReader(new InputStreamReader(url.openStream(), encoding)); StringBuffer sb = new StringBuffer(); String line; while ((line = br.readLine()) != null) { sb.append(line).append("\n"); ... |
String | readUrlText(String urlString) read Url Text URL url = new URL(urlString); InputStream stream = url.openStream(); StringBuilder buf = new StringBuilder(); BufferedReader in = null; try { in = new BufferedReader(new InputStreamReader(stream)); String str; while ((str = in.readLine()) != null) { ... |
StringBuffer | readURLText(URL url, StringBuffer errorText) Returns the raw text (i.e. StringBuffer page = new StringBuffer(""); String thisLine; try { BufferedReader source = new BufferedReader(new InputStreamReader(url.openStream())); while ((thisLine = source.readLine()) != null) { page.append(thisLine + "\n"); return page; ... |
byte[] | readURLThrowException(final String url) read URL Throw Exception byte[] data = null; InputStream inputStream = null; try { inputStream = new URL(url).openStream(); data = getBytes(inputStream, -1); inputStream.close(); } finally { inputStream.close(); ... |