downloadWebpage() problem
im trying to build a custom webpage + RSS reader from scratch.
the method shown below works for the most part. but it will always get this Exception "java.net.SocketException: Unexpected end of file from server" whenever a RSS is from "www.nyaatorrents.org".
but, when i open a RSS using RssReader, it works. so, what am i missing here?
Code:
public static String downloadWebpage(final String urlString) {
URL url;
InputStream is = null;
DataInputStream dis;
String line;
StringBuffer buffer = new StringBuffer();
try {
url = new URL(urlString);
is = url.openStream(); // throws an IOException
dis = new DataInputStream(new BufferedInputStream(is));
while ((line = dis.readLine()) != null) {
buffer.append(line + "\n");
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
is.close();
} catch (Exception err) {}
finally{
return buffer.toString();
}
}
}