Why does InputStream#read()
return an int
and not a byte
?
Because a byte
can only hold -128 until 127, while it should return 0 until 255 (and -1 when there's no byte left (i.e. EOF)). Even if it returned byte
, there would be no room to represent EOF.
A more interesting question is why it doesn't return short
.