Why does InputStream#read() return an int and not a byte?
Why does InputStream#read() return an int and not a byte ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Because a
bytecan 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 returnedbyte, there would be no room to represent EOF.A more interesting question is why it doesn’t return
short.