0

I have a question about the IO classes of Java.

The classes that ending with Reader return the int of the read char.

The classes that ending with Stream return the value of byte of the read byte (from 0 to 255).

So, I don't understand why for the Reader the EOF alert value is -1 and for Stream is null. Why?

Thanks a lot!

A.

Sam
  • 536
  • 5
  • 23
  • 1
    Hope this solves your problem. https://stackoverflow.com/questions/611760/java-inputstream-blocking-read – Anoob C I Apr 16 '19 at 11:37
  • 1
    Well, [`Reader.read()`](https://docs.oracle.com/en/java/javase/12/docs/api/java.base/java/io/Reader.html#read()) and [`InputStream().read()`](https://docs.oracle.com/en/java/javase/12/docs/api/java.base/java/io/InputStream.html#read()) both return -1 at the end of input, so there is no difference. – Thomas Apr 16 '19 at 11:42
  • Where did you see that the EOF value for Stream is null? – DodgyCodeException Apr 16 '19 at 11:47

0 Answers0