Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problems reading InputStream through proxy

Sudhir Akella
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am trying to download a webpage, through a proxy server, as an InputStream. Then I read the InputStream into a buffer (byte[]) and feed it to a ByteArrayOutputStream. After few iterations in the while loop, it hangs ...
This only occurs if the webpage is of large size or if there are several links in the main page and each link has to be extracted in a loop.

There is no problem if the proxy is removed from the picture. I have pasted the code sample at the very end.

Any suggestions would be of great help.

Thanks in advance,

Sudhir Akella

--------------- CODE SAMPLE ----------->

/** The argument InputStream is extracted for any website */

String inputStreamToString(InputStream is){
byte[] filebuffer = null;
ByteArrayOutputStream bos = new ByteArrayOutputStream();
try {
byte[] buffer = new byte[10000];
int readCount = 0;

while(true) {
readCount =; // *** Hangs here
if (readCount > 0) {
bos.write(buffer, 0, readCount);
else break;

filebuffer = bos.toByteArray();
catch (IOException e) {
String html = new String (filebuffer);
return html;
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic