Difference between InputStream and Reader in Java IO

Stream and Reader are both abstractions in Java to help programmer deal with IO. It's doesn't where your data comes from, file, string, network, you get an uniform API to get data from the abstraction. But they are different level of abstraction.

Bytes vs Characters

The fundamental difference between InputStream and Reader in Java is stream works with bytes, reader works with characters. They are different layer of abstractions.

It's the same as the difference between data and information. Data is just streams of binary, the combination of 1 and 0, it's only meaningful for machine. Information is for human. It has shapes, structures, and can be consumed by human.

Data just a form to carry the information. The same information be stored and displayed in computer or in a paper book, just different form.

In software, that's two levels of abstraction. It's better to separate them, the single responsibility principle must be followed.

Each layer has it's own concerns about the problem, the stream layer needs to deal with hard disk or network connection, to get in get out data as efficient as possible. Reader layer needs to care the encoding, line ending, Unicode and stuff like that.

You can see the difference by looking at the method signatures of stream and reader class.

Reader gives you char and string. In Java all string are Unicode, you just can't get a string from InputStream.