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

StringreadURL(String url, String charsetName)
read URL
try {
    java.net.URL u = new java.net.URL(url);
    return readAsText(u.openStream(), charsetName);
} catch (Exception exp) {
    throw new RuntimeException("readURL error!", exp);
ArrayListReadURL(String URLAddress)
Reads data from an URLAddress to the string
URL address;
try {
    address = new URL(URLAddress);
} catch (MalformedURLException ex) {
    return null;
ArrayList<String> sb = new ArrayList();
try {
...
StringreadUrl(String urlString)
read Url
URL url = new URL(urlString);
try (BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()))) {
    StringBuilder buffer = new StringBuilder();
    int read;
    char[] chars = new char[1024];
    while ((read = reader.read(chars)) != -1)
        buffer.append(chars, 0, read);
    return buffer.toString();
...
StringreadURL(URL fileURL)
read URL
return readAll(new InputStreamReader(fileURL.openStream()));
StringreadURL(URL url)
read URL
final StringBuilder content = new StringBuilder();
final BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
    content.append(inputLine);
in.close();
return content.toString();
StringreadURL(URL url)
read URL
try {
    InputStreamReader in = new InputStreamReader(url.openStream());
    char[] buffer = new char[1024];
    int l = 0;
    StringBuilder sb = new StringBuilder();
    while ((l = in.read(buffer, 0, buffer.length)) > -1) {
        sb.append(buffer, 0, l);
    in.close();
    return new String(sb);
} catch (Exception e) {
    e.printStackTrace();
return null;
StringreadURL(URL url)
read URL
ByteArrayOutputStream baos = new ByteArrayOutputStream();
InputStream is = url.openStream();
int r;
while ((r = is.read()) != -1) {
    baos.write(r);
return new String(baos.toByteArray());
StringreadURL(URL url)
Read from a URL into a string
String str = "";
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
    str += inputLine + "\n";
in.close();
return str;
StringreadUrl(URL url)
read Url
BufferedReader reader = null;
StringBuilder buffer = new StringBuilder();
try {
    reader = new BufferedReader(new InputStreamReader(url.openStream()));
    int read;
    char[] chars = new char[1024];
    while ((read = reader.read(chars)) != -1)
        buffer.append(chars, 0, read);
...
StringreadURLasString(URL url)
read UR Las String
InputStream openStream = url.openStream();
try {
    InputStreamReader inStream = new InputStreamReader(openStream);
    try {
        BufferedReader inReader = new BufferedReader(inStream);
        try {
            String oneLine = inReader.readLine();
            if (oneLine == null)
...