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

StringreadUrlContent(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);
...
StringreadURLContents(String UrlText)
read URL Contents
try {
    InputStream in = openURLStream(UrlText);
    String page = readStream(in);
    return (page);
} catch (IOException ex) {
    throw new IllegalArgumentException(ex.toString()); 
JSONArrayreadURLJSONArray(String urlString)
read URLJSON Array
try {
    return new JSONArray(readURL(urlString));
} catch (JSONException e) {
    return null;
PropertiesreadUrlProperties(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) {
...
StringreadUrlStream(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);
StringreadUrlText(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");
...
StringreadURLText(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");
...
StringreadUrlText(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) {
...
StringBufferreadURLText(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();
...