In order to return values that can't be represented in Java data type byte
.
An unsigned byte holds a zero or positive value.
An unsigned byte in a file holds values 0 to +255.
But, in Java (regardless of computer platform),
the primitive type byte
holds an integer in the range -128 to +127.
So the method uses data type int
which can hold the negative values from 128 to 255.
(Review: ) What happens when readInt()
reaches the end of the file?