aspose file tools*
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 8707
    
    6

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]
 
wood burning stoves
 
subject: How to tell JVM to wait for the Stream?
 
Similar Threads
org.apache.commons.httpclient response not getting
Java newbie question
Trying to figure out why Im getting "cannot be resolved" error
SocketException:socket closed
Calling a SharePoint Web Service using dynamic invocation procedure with NTLM authentication?