 <p>Unfortunately it is something related with a bad design of the class <code>InputStream</code>. If you use <a href="https://docs.oracle.com/javase/7/docs/api/java/io/InputStream.html#read()" rel="nofollow">read()</a> you will have that problem. You should use <a href="https://docs.oracle.com/javase/7/docs/api/java/io/InputStream.html#read(byte[])" rel="nofollow">read(byte[])</a> instead. But as you say, you could also use <code>Int</code>. That is up to you.</p>