my dog learned polymorphism*
The moose likes I/O and Streams and the fly likes Buffered Reader not ready Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Buffered Reader not ready" Watch "Buffered Reader not ready" New topic

Buffered Reader not ready

Dilshan Edirisuriya
Ranch Hand

Joined: Apr 22, 2006
Posts: 299
I am using a BufferedReader to read remote site content of a web site. I am using ready() method to check whether the stream is ready and if so iterating through it. In some cases it does not enter into the loop cos the buffered ready is indicating it is NOT READY. Hence I used a thread sleep of 2 seconds to delay the process and it resulted in my expected output. So what will be the reason for this behavior and what will be the actual way I should write this.

Thank You

Dilshan Edirisuriya SCJP1.4, SCWCD1.4, SCBCD 5
Rob Spoor

Joined: Oct 27, 2005
Posts: 19552

The same applies to ready().

How To Ask Questions How To Answer Questions
Dilshan Edirisuriya
Ranch Hand

Joined: Apr 22, 2006
Posts: 299
Thank you Rob for the reply.
I agree. Here's the link:
subject: Buffered Reader not ready
Similar Threads
Ensuring that no one hacks my site.
Problem in reading empty line
how to zip file clubbing ZipOutputStream in Buffered writer
VTD XML buffer re-use