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

StringreadResource(URL resource)
read Resource
try (InputStream is = resource.openStream()) {
    Scanner s = new Scanner(is).useDelimiter(FILE_DELIMITER);
    return s.hasNext() ? s.next() : "";
voidreadServicesFromUrl(Collection list, URL url)
read Services From Url
InputStream in = url.openStream();
try {
    if (in == null)
        return;
    BufferedReader r = new BufferedReader(new InputStreamReader(in, "UTF-8"));
    while (true) {
        String line = r.readLine();
        if (line == null)
...
String[]readSqlStatements(URL url)
Reads SQL statements from file.
try {
    char buffer[] = new char[256];
    StringBuilder result = new StringBuilder();
    InputStreamReader reader = new InputStreamReader(url.openStream(), "UTF-8");
    while (true) {
        int count = reader.read(buffer);
        if (count < 0) {
            break;
...
SetreadStopwordsURL(URL url, boolean lowercase)
read Stopwords URL
return readStopwordsInputStream(url.openStream(), lowercase);
StringreadStringFromUrl(URL url)
Reads content from specified URL
StringBuffer buffer = new StringBuffer();
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
int ch;
while ((ch = in.read()) != -1) {
    buffer.append((char) ch);
in.close();
return buffer.toString();
...
StringreadStringFromURL(URL url)
read String From URL
InputStream is = null;
try {
    is = url.openStream();
} catch (IOException e) {
    return "";
return readStringFromInputStream(is);
StringreadText(final URL url)
read Text
String text = null;
BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
StringBuilder sb = new StringBuilder();
String next;
while ((next = br.readLine()) != null) {
    sb.append(next + System.getProperty("line.separator"));
br.close();
...
StringreadText(final URL url)
Reads text from the specified URL.
if (url == null)
    throw new IOException("File not found");
final InputStream stream = url.openStream();
try {
    final ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    final byte[] buffer = new byte[8192];
    int read;
    while ((read = stream.read(buffer)) > 0) {
...
StringreadTextFile(final URL resource)
Reads a text file (UTF-8 encoding) from the specified resource.
if (resource == null)
    throw new IOException("Resource not found");
try (final InputStream stream = resource.openStream()) {
    return readTextFile(stream);
StringreadTextFileAtUrl(final URL url)
read Text File At Url
BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
StringBuilder sb = new StringBuilder();
String inputLine;
while ((inputLine = br.readLine()) != null) {
    sb.append(inputLine + "\n");
br.close();
return sb.toString();
...