This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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

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: 20078

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
It's not a secret anymore!