posted 11 years ago
It's definitely worth putting the transferTo() call into a loop, as Rob suggested. Nothing in the docs indicates that the call is guaranteed to transfer all available bytes, and they do provide the return value that tells you how many bytes they did transfer. So you need to check that value and use it, as Rob showed.
It's not a very user-friendly API. They should really provide a method that simply does what is requested, and either blocks until done, or throws an error if it can't. Because that's what many users expect. But it's not what the docs say, and it's not what they did.