wood burning stoves 2.0*
The moose likes I/O and Streams and the fly likes How to tell JVM to wait for the Stream? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "How to tell JVM to wait for the Stream?" Watch "How to tell JVM to wait for the Stream?" New topic
Author

How to tell JVM to wait for the Stream?

Jason Bock
Greenhorn

Joined: Dec 27, 2008
Posts: 19
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

Joined: Oct 29, 2001
Posts: 8836
    
    7

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.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
 
Consider Paul's rocket mass heater.
 
subject: How to tell JVM to wait for the Stream?
 
Similar Threads
Calling a SharePoint Web Service using dynamic invocation procedure with NTLM authentication?
Java newbie question
Trying to figure out why Im getting "cannot be resolved" error
org.apache.commons.httpclient response not getting
SocketException:socket closed