Java Utililty Methods URL Load

List of utility methods to do URL Load

Description

The list of methods to do URL Load are organized into topic(s).

Method

voidloadProps(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);
JsonObjectloadRemoteJSON(final URL source)
load Remote JSON
return GSON.fromJson(new InputStreamReader(source.openStream()), JsonObject.class);
StringloadText(URL url, boolean allowCache)
Loads the text from the given URL and returns it as a string.
return new String(load(url, allowCache));
StringBufferloadURL(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) {
...
ListloadUrlToList(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()));
StringloadURLToString(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;
...
BufferedReaderread(String url)
read
return new BufferedReader(new InputStreamReader(new URL(url).openStream()));