On 2/17/07, Roland Weber <[EMAIL PROTECTED]> wrote:
For heaven's sake, don't you read JavaDocs? http://java.sun.com/j2se/1.4.2/docs/api/java/io/Reader.html#ready() ready() tells you whether there is data available _without_blocking_! It does NOT tell you whether you're at the end of the stream. Specifications and JavaDocs are the reference for API behavior, not trial-and-error results with one or two sites and a debugger.
Yeah, I know that and obviously I am using them all the time but I got confused by the fact it was working on some servers and completely overlooked that. Sorry for that. Well, than that page happens to be very small (<4k) and the
Wikipedia server does not flush the output stream after the HTTP header and before the HTTP body. If the body happens to be transferred in the same IP packet as the end of the header, it is buffered locally on the client and will be detected by available() and ready(). If the body is transferred in a separate IP packet, or does not fit into a single packet, available() will NOT return how much data there is in the page, but only how much of that happens to be buffered on the client. Which might be 0. If you're reading from either an InputStream or a Reader, you read _blocking_ until the read(...) method you're using returns a negative value. THEN you're at the end of the stream.
Thanks a lot for your explanations and your patience. Everything is working fine now. Regards, Gaƫl
