rendered paste body public String fetchURLStream(String targetUrl) throws MalformedURLException, ConnectException, IOException {
URL url = new URL(targetUrl);
InputStream in = url.openStream();
return processStream(in);
}
protected String processStream(InputStream is) throws IOException {
return processStream(new InputStreamReader(is));
}
protected String processStream(Reader r) throws IOException {
BufferedReader br = new BufferedReader(r);
StringBuffer sb = new StringBuffer();
String tmp = br.readLine();
while (tmp != null) {
sb.append(tmp);
sb.append("\n");
tmp = br.readLine();
}
r.close();
return sb.toString();
}