API中的解释为:Reads the next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned.
意思是每次从流中读取一比特数据。你可能会问为什么不返回byte数组。这就需要读源码了。
大概的原因就是。如果我们读去的流中有连续8个1,那么这个值在计算机内部表示-1;正好等于结束循环的标记,因此向上转型为int则避免了这个情况 的发生 |