This discussion is archived
3 Replies Latest reply: Jun 3, 2009 7:51 AM by 796447 RSS

Detecting end of stream in Inputstream

843789 Newbie
Currently Being Moderated
I'm new to java, and there are several things I am not familiar with.

I want to download a web page. I have looked at the sample code here:

and other code like it (using URLConnection, for example). I don't understand how to detect that the entire file has been downloaded. the code
while ((inputLine = in.readLine()) != null)
doesn't seem to differentiate between a true end and just a not-ready condition. What actually happens if the buffer is still filling? What if the server puts a gap in transmission, leaving the buffer empty for a moment?

Would someone clarify this for me, please?