File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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
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: 8964
    
    9

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.


[How To Ask Questions On JavaRanch]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to tell JVM to wait for the Stream?