List of utility methods to do URL Load
void | loadProps(URL url, Properties props) load Props InputStream inputStream = null; if (url != null) { inputStream = url.openStream(); } else { System.out.println("Props File not Found"); props.load(inputStream); |
JsonObject | loadRemoteJSON(final URL source) load Remote JSON return GSON.fromJson(new InputStreamReader(source.openStream()), JsonObject.class); |
String | loadText(URL url, boolean allowCache) Loads the text from the given URL and returns it as a string. return new String(load(url, allowCache)); |
StringBuffer | loadURL(String urlDesc) load URL StringBuffer buffer = new StringBuffer(); try { URL urlContent = new URL(urlDesc); BufferedReader inBuf = new BufferedReader(new InputStreamReader(urlContent.openStream())); String strTemp; while ((strTemp = inBuf.readLine()) != null) buffer.append(strTemp + "\r\n"); inBuf.close(); ... |
byte[] | loadURL(URL url) load URL int bufSize = 1024 * 2; byte[] buf = new byte[bufSize]; ByteArrayOutputStream bout = new ByteArrayOutputStream(); BufferedInputStream in = new BufferedInputStream(url.openStream()); int n; while ((n = in.read(buf)) > 0) { bout.write(buf, 0, n); try { in.close(); } catch (Exception ignored) { return bout.toByteArray(); |
byte[] | loadURL(URL url) Load URL contents int a byte array byte[] buf = new byte[1024]; InputStream is = null; ByteArrayOutputStream bout = new ByteArrayOutputStream(); try { is = url.openStream(); int n; while (-1 != (n = is.read(buf))) { bout.write(buf, 0, n); ... |
byte[] | loadUrlIntoByteArray(String urlString) load Url Into Byte Array URL url = new URL(urlString); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); InputStream inputStream = null; try { inputStream = url.openStream(); byte[] byteChunk = new byte[8192]; int n; while ((n = inputStream.read(byteChunk)) > 0) { ... |
List | loadUrlToList(URL iUrl) Reads text from a remote URL into a list of strings, each containing one line of the file. return loadReaderToList(new InputStreamReader(iUrl.openStream())); |
String | loadURLToString(String url, String EOL) Loads a web page from an URL to a string. BufferedReader in = new BufferedReader(new InputStreamReader((new URL(url)).openStream())); String result = ""; String str; while ((str = in.readLine()) != null) { result += str + EOL; in.close(); return result; ... |
BufferedReader | read(String url) read return new BufferedReader(new InputStreamReader(new URL(url).openStream())); |