Possible Duplicate:
Why does InputStream#read() return an int and not a byte?
Hey I was just surfing java docs for material on I/O streams and just came across this question specifically in reference to the byte streams – If the input is a stream of bytes, why doesn’t read() return a byte value ?
I scratched my head for some time but couldn’t think of any strong answer to the question I would be grateful if anyone can help.
This is because
readcan return -1 as an indicator of end-of-stream (EOF) marker – i.e. no more bytes to be read from the stream.More details: http://download.oracle.com/javase/1.4.2/docs/api/java/io/InputStream.html#read%28%29 . Specifically: