What is the difference between a stream and a reader in Java?

Home / Uncategorized / What is the difference between a stream and a reader in Java?

Question:
Today I got this question for which I think I answered very bad. I said stream is a data that flows and reader is a technique where we read from that is a static data. I know this is an awful answer, so please provide me the crisp difference and definitions between these two with example in Java.

Thanks.


Answer:
As others have said, the use cases for each are slightly different (even though they often can be used interchangeably)

Since readers are for reading characters, they are better when you are dealing with input that is of a textual nature (or data represented as characters). I say better because Readers (in the context of typical usage) are essentially streams with methods that easily facilitate reading character input.
Read more

Leave a Reply

Your email address will not be published. Required fields are marked *