I am frequently getting a \'Premature EOF\' Exception when reading a web page.
The following is the StackTrace
java.io.IOException: Premature EOF
This may be because you are reading the content line by line and for the last line the file may be missing a return, to signal the end of line. Replace your while with this:
int BUFFER_SIZE=1024;
char[] buffer = new char[BUFFER_SIZE]; // or some other size,
int charsRead = 0;
while ( (charsRead = rd.read(buffer, 0, BUFFER_SIZE)) != -1) {
sb.append(buffer, 0, charsRead);
}