InputStream.read
is not required to read all the data. It will read some data, with an amount varying between 1 and the size of the array.
You will have to call the function repeatedly until you read all the data you need.
For reference, check the API docs: they explicitly say "a smaller number may be read".