}
return text;
}
protected String readTextFromStream(InputStream aTextStream) {
Charset charset = getCharSet();
int size = urlConnection.getContentLength();
ByteArrayOutputStream bos = new ByteArrayOutputStream(size != -1 ? size : 1024);
byte[] buffer = new byte[1024];
int len;
try {
while ((len = aTextStream.read(buffer)) != -1) {
bos.write(buffer, 0, len);
}
} catch (IOException e) {
e.printStackTrace();
}
String streamedText = ""; // be robust
try {
streamedText = bos.toString(charset.name());
} catch (UnsupportedEncodingException e) {} // we already checked for that above
// check Content-Type text/plain; charset=iso-8859-1
return streamedText;
}