End of stream in JAVA
I am confused by the following statement that appears here
The main read () method of the InputStream class reads one unsigned byte of data and returns an unsigned int byte. This is a number between 0 and 255. If the end of the stream collides, it returns -1; and you can use this as a flag to keep track of the end of the stream.
Since a single byte can represent up to 256 integers, I don't see how it can represent 0 to 256 and -1. Can someone please comment on what I am missing here?
+3
source to share
3 answers
The return type of InputStream # read () is int
where the value can be read as byte
if it falls in the range 0-255.
+3
source to share