• 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
Posts: 9370
11
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.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!