• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to tell JVM to wait for the Stream?

 
Jason Bock
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using Apache's HttpClient to retrieve the page, and IOUtils to process the stream.

Often times the method finishes executing and returns response before the stream gets to finish processing, and my html variable ends up empty.

What can I do to prevent this from happening? How can I tell it to wait for the stream to finish, er, streaming?

My understanding was that IOUtils uses a BufferedReader to wait for the stream to finish before doing anything else, but that doesn't seem to be the case.

 
Joe Ess
Bartender
Pie
Posts: 9257
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about catching and printing out the possible exception? Right now, if you get an exception trying to read the response, you'd never know.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic