Rob Spoor wrote:That's a common problem with HTTP connections - the input stream doesn't end when the body does. You really have to a) use the content length, or b) check for specific markers that are content-type specific.
Assuming you have the content length:
Dave Tolls wrote:read does not fill up the byte.
It fills up what it can, based on what is available on the stream.
This is very unlikely (for something large) to be all the data of your file.
The key to that is the number returned by read. Do not ignore this, as it tells you how much was read in.
So what is happening is you are creating a byte buffer and then doing a read on it, but the stream cannot fill the buffer as not all the data has been received.
You then use what there is in the buffer, ignoring that read has told you it hasn't filled it.
Tim Nachreiner wrote:I viewed your source code and was impressed.
Is this a tutorial you are following?
If so, would you share the link?